473,378 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Add a .js file to an aspx using inheritance

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 =---
Nov 15 '05 #1
2 4255
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]
- mv*@spam.guard.caspershouse.com

"elbomberotorero" <el*************@hotmail-dot-com.no-spam.invalid> wrote in
message news:40********@127.0.0.1...
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

=---
Nov 15 '05 #2
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?

----== 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 =---
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
I have two classes and a web page: test1.cs, test2.cs, and test.aspx. I know how to add a reference to test1.cs from test.aspx using the assembly directive (<%@ Assembly Src="test1.cs" %>). This...
5
by: Guoqi Zheng | last post by:
Dear sir, If I need to use a function on xxx.aspx page, e.g. on a repeater control, I have to define this function inside xxx.aspx.vb file, if I put it in the module class, it will not work so I...
9
by: Ryan Ternier | last post by:
I just got moved to a project that has an inheritance structure sort of like this: MyWebPage.aspx inherits ---> MyWebPage.ASPX.VB inherits ----> Utility.VB inherits -----> DHTMLMenu.vb...
6
by: mister.mwa | last post by:
Hello, I have the following problem: I have a class Foo, and a class Bar. I want Foo to inherit from Bar, but i want to put them in separate files Foo.vb and Bar.vb. Then i will use the Foo...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
9
by: Alan Silver | last post by:
Hello, I have a user control which I am trying to load dynamically, but am running into problems. I think the problem is because I have two .ascx files that refer to the same .ascx.cs file. A...
3
by: savvy | last post by:
I'm using "Visual Studio 2005 Professional". I'm half way through in my project development. I've created a New Website in the Visual Studio 2005 and developing my project over there. When i wanted...
2
by: Hiten | last post by:
Is it possible to have more code behind file but that file will have same class in way of partial class, Default Structure I -------------- Homepage.aspx + Homepage.aspx.cs (this .cs file...
7
by: iguana84 | last post by:
Hi, I have a newbie question for (ASP.Net 2.0 framework) which is based on Design Pattern / Coding Trick --> I need to :- - Inherit one aspx page and its code (super abstract class)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.