p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/asp-net-3-5-basics-351/)
-   -   How to add a script file programtically? (http://p2p.wrox.com/asp-net-3-5-basics/72951-how-add-script-file-programtically.html)

chobo2 February 25th, 2009 05:41 PM

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.


Lee Dumond February 25th, 2009 05:49 PM

Please see the following blog post:

The Controls Collection Cannot Be Modified Because the Control Contains Code Blocks

chobo2 February 25th, 2009 07:02 PM


Originally Posted by Lee Dumond (Post 235662)

Thanks your a lifesaver lol.

How would you add a script in C# codebehind? Just curious.

iceman90289 February 26th, 2009 06:58 PM

Using the Grid View
okay so basically i use the login control to make my account on my website (aside from the issue that i can not log in with that account more than once...), i want to use the gridview to show all the members. the problem is it shows everything, security answer/question, is online, provider, etc... i just want to pull out the isonline and UserName columns but idk what table the data is being held in i looked at the tables folder in the database manager on VWD and there is no table i see with those column names.

if anyone can show me how to display:

Member Name IsOnline

in a grid view. or anything like that. let me know...maybe i should use a different control? my thanks in advance

iceman90289 February 26th, 2009 07:01 PM

oops. this isnt a new thread... my bad

Lee Dumond February 26th, 2009 07:02 PM


I might suggest you post this question in a new thread, rather than sticking it in a totally unrelated thread like this. More people will see it that way.

iceman90289 February 26th, 2009 07:14 PM

i know i know... i minimized the window and forgot where i was at... i thought i was making a thread but i was looking up the answer to his question.


<%@ Page Language="C#" AutoEventWireUp="true" CodeFile="FirstPageCodeBehind.aspx.cs" Inherits=classname %>

Code File is self explanitory but Inherits links you to the class in the code file. just type a class name.

All times are GMT -4. The time now is 08:19 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.