View Single Post
  #1 (permalink)  
Old February 25th, 2009, 05:41 PM
chobo2 chobo2 is offline
Friend of Wrox
Join Date: Sep 2007
Location: , , .
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default How to add a script file programtically?


I have a jquery script that I need to add to my pages through C# code. The way I am doing it now causes trouble with the .net ajax toolkit.

I have it like this

<script src="<%= ResolveClientUrl("Javascripts/jquery-1.3.1.min.js") %>" type="text/javascript"></script>

I am using ResolveClientUrl because I have some pathing issues if I don't.

But when I have anything from the toolkit I get this error

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

I found a person saying that to avoid this you have to put your script programatically in but I don't know how to do this.