Modifying head tag of parent file.

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Mar 2005
Posts: 960
Reputation: belama is an unknown quantity at this point 
Solved Threads: 2
belama's Avatar
belama belama is offline Offline
Posting Shark

Modifying head tag of parent file.

 
0
  #1
May 17th, 2005
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:

  1. System.Web.UI.HtmlControls.HtmlGenericControl a = (System.Web.UI.HtmlControls.HtmlGenericControl)this.Parent.Parent.Controls[1];
  2. 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...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Modifying head tag of parent file.

 
0
  #2
May 27th, 2005
Can you use the "RegisterClientScriptBlock()" method, instead?
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 960
Reputation: belama is an unknown quantity at this point 
Solved Threads: 2
belama's Avatar
belama belama is offline Offline
Posting Shark

Re: Modifying head tag of parent file.

 
0
  #3
May 27th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC