Add a .js file to an aspx using inheritance

  • Thread starter Thread starter elbomberotorero
  • Start date Start date
E

elbomberotorero

Hi everyone,

I have several aspx files which inherit from a common file called
Menu.

In this file, I overwrite the Page_Load method and I put inside it the
LoadControl method to load an user control to the daughters without
having these any code line referred to that control (@Register
control, ...).

Now, I would like to do the same for the js files and the css files. I
would like to add them just by inheritance and not by code or by
using "id" or "runat='server'" inside the webforms.

Is there any solution apart from parsing the HTML, looking for the
"head" tag, adding the code and substituting the control?
 
elbomberotorero,

Yes, you can do this. In your control, at some point, you have to make
a call to the RegisterStartupScript method on the Page class (which you can
get through the control), passing in the javascript (or reference) which you
will need.

As for CSS files, I am not sure if you can do that, but you might have
to inject that directly into the stream.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

elbomberotorero said:
Hi everyone,

I have several aspx files which inherit from a common file called
Menu.

In this file, I overwrite the Page_Load method and I put inside it the
LoadControl method to load an user control to the daughters without
having these any code line referred to that control (@Register
control, ...).

Now, I would like to do the same for the js files and the css files. I
would like to add them just by inheritance and not by code or by
using "id" or "runat='server'" inside the webforms.

Is there any solution apart from parsing the HTML, looking for the
"head" tag, adding the code and substituting the control?



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Thanx,

I've achieved to inherit the js file using RegisterClientScriptBlock
and it works!!!!!!!!


I dont understand what you mean about inject it into the stream. Any
example?
 
Back
Top