DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Modifying head tag of parent file. (http://www.daniweb.com/forums/thread23727.html)

belama May 17th, 2005 12:56 pm
Modifying head tag of parent file.
 
Right now, I have a project with a class of a custom control. I also have a project with an .aspx file and its back code that implements the control of my other class.

In the control's class, I need to write code that will add some javascript in the head tag of web pages that will use this control.

I found out that with this code:

System.Web.UI.HtmlControls.HtmlGenericControl a = (System.Web.UI.HtmlControls.HtmlGenericControl)this.Parent.Parent.Controls[1];
a.InnerHtml += "<script type=\"text/javascript\" src=\"" + "file.js\"></script>";

I can do it but I need the users to add runat="server" to the head tag of their pages for it to work.

Does anyone know how I would do this without modifying the aspx file's head tag?

Thank you very much...

tgreer May 27th, 2005 1:56 pm
Re: Modifying head tag of parent file.
 
Can you use the "RegisterClientScriptBlock()" method, instead?

belama May 27th, 2005 5:47 pm
Re: Modifying head tag of parent file.
 
I thought of something like that today. It'll also be good to prevent the code from writing to the page more than onece if I have multiple instances of the control.

thanks


All times are GMT -4. The time now is 12:01 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC