0
votes

I am using to use <%= %> inside server controls and gives me error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

This is my code:

 <asp:Menu runat="server" >
        <Items>
            <asp:MenuItem Text="Candidates" NavigateUrl="<%=Constants.AccountPageUrl %>" />
        </Items>
 </asp:Menu>
1
Is the control being loaded into a Master page?Chris Gessler
Or try it without enclosing it in double quotes! NavigateUrl=<%= varName %>Stokedout

1 Answers

0
votes

try the following.. It may help you

NavigateUrl="<%#Constants.AccountPageUrl %>"