web analytics

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

Options

codeling 1573 - 6555
@2019-01-18 08:38:13

When I try to "~" character to the path value assigned to the attribute src in a ASP.NET web page,

<script runat="server" type="text/javascript" src="~/jquery.js"></script>

I get the following error from IIS:

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

 

 

@2019-01-18 08:43:12

Try <%# instead of <%= in the aspx web page under head section

<script type="text/javascript" 
        src="<%# ResolveUrl("~/jquery.js") %>">
</script>

Then in Code Behind of Master page under Page_Load Event

Page.Header.DataBind();

Now you are good to go with either jQuery and JavaScript as well as CSS just you need to change your path in ResolveUrl which file you want to handle CSS, JavaScript, jQuery.

Comments

You must Sign In to comment on this topic.


© 2022 Digcode.com