web analytics
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) Options
codeling
Posted: Friday, January 18, 2019 8:38:13 AM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 994
Points: 4191

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. <% ... %>)

 

 

Sponsor
Posted: Friday, January 18, 2019 8:38:13 AM
 
codeling
Posted: Friday, January 18, 2019 8:43:12 AM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 994
Points: 4191

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.

Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2019 Digcode.com. All rights reserved.