473,394 Members | 1,769 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,394 software developers and data experts.

Dynamically add the stylesheet(.CSS file)

VSK
Hi,

Iam looking for a way to dynamically add the stylesheet.

I have all the .aspx pages extend from a CommonPage.cs which extend from
System.Web.UI.Page.

Now i want a way to detect the browser(netsacpe/ie) and load the curr .css
file in CommonPage so that it applies to all the pages which extend from
commonpage.

Is there a way i can do.

any inputs will be helpful

Thx
VSK
Nov 18 '05 #1
3 1995
VSK,

I think the easiest way would be to turn the style tag into a server side
control.

Set your style tag to look like this (with the href set to a default style
sheet):

<LINK id="StyleTag" runat="server" rel="stylesheet" type="text/css"
href="http://localhost/lab/styles.css">

Please note that I've added the attributes: id and runat to the tag.

Now in the code-behind page declare a matching object for the "StyleTag" id
like this:

Protected StyleTag As System.Web.UI.HtmlControls.HtmlGenericControl

Now you can use the StyleTag object to set any attribute from the
code-behind page.

In order to do what you want (change the href) you would use code like this:

StyleTag.Attributes.Add("href", "http://localhost/lab/NewStyles.css")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VSK" <vs*****@hotmail.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi,

Iam looking for a way to dynamically add the stylesheet.

I have all the .aspx pages extend from a CommonPage.cs which extend from
System.Web.UI.Page.

Now i want a way to detect the browser(netsacpe/ie) and load the curr .css
file in CommonPage so that it applies to all the pages which extend from
commonpage.

Is there a way i can do.

any inputs will be helpful

Thx
VSK

Nov 18 '05 #2
VSK
Thanks a lot!

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
VSK,

I think the easiest way would be to turn the style tag into a server side
control.

Set your style tag to look like this (with the href set to a default style
sheet):

<LINK id="StyleTag" runat="server" rel="stylesheet" type="text/css"
href="http://localhost/lab/styles.css">

Please note that I've added the attributes: id and runat to the tag.

Now in the code-behind page declare a matching object for the "StyleTag" id like this:

Protected StyleTag As System.Web.UI.HtmlControls.HtmlGenericControl

Now you can use the StyleTag object to set any attribute from the
code-behind page.

In order to do what you want (change the href) you would use code like this:
StyleTag.Attributes.Add("href", "http://localhost/lab/NewStyles.css")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VSK" <vs*****@hotmail.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi,

Iam looking for a way to dynamically add the stylesheet.

I have all the .aspx pages extend from a CommonPage.cs which extend from
System.Web.UI.Page.

Now i want a way to detect the browser(netsacpe/ie) and load the curr ..css file in CommonPage so that it applies to all the pages which extend from
commonpage.

Is there a way i can do.

any inputs will be helpful

Thx
VSK


Nov 18 '05 #3
VSK

You're Welcome. :)

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VSK" <vs*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks a lot!

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
VSK,

I think the easiest way would be to turn the style tag into a server side
control.

Set your style tag to look like this (with the href set to a default style sheet):

<LINK id="StyleTag" runat="server" rel="stylesheet" type="text/css"
href="http://localhost/lab/styles.css">

Please note that I've added the attributes: id and runat to the tag.

Now in the code-behind page declare a matching object for the "StyleTag"

id
like this:

Protected StyleTag As System.Web.UI.HtmlControls.HtmlGenericControl

Now you can use the StyleTag object to set any attribute from the
code-behind page.

In order to do what you want (change the href) you would use code like

this:

StyleTag.Attributes.Add("href", "http://localhost/lab/NewStyles.css")
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VSK" <vs*****@hotmail.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
Hi,

Iam looking for a way to dynamically add the stylesheet.

I have all the .aspx pages extend from a CommonPage.cs which extend from System.Web.UI.Page.

Now i want a way to detect the browser(netsacpe/ie) and load the curr

.css file in CommonPage so that it applies to all the pages which extend from commonpage.

Is there a way i can do.

any inputs will be helpful

Thx
VSK



Nov 18 '05 #4

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

Similar topics

2
by: Markus Ernst | last post by:
Hi I build a small content management system. I use different external stylesheets for the admin section and the frontend, called admin.css and frontend.css. Now I would like to preview some...
26
by: HarryO | last post by:
I created an external stylesheet file 'styles.css' and an html file that includes the line: <LINK REL="stylesheet" TYPE="text/css" HREF="styles.css" Both the .css file and the html file reside...
5
by: aamirghanchi | last post by:
Hi, I have a very simple html that has a linked stylesheet. According to the style sheet both blocks of text should be displayed in the font xx-small. but only one (DIV or SPAN) at a time is...
4
by: Ravindra | last post by:
Hi all I have created a stylesheet file (.css) and included in all my web form pages. This stylesheet contains colors and fonts for headings, text, body backgrounds, and for tables. And these...
6
by: shapper | last post by:
Hello, How to create a CSS StyleSheet at runtime and added it an Asp:Label? I am using Asp.Net 2.0. Thanks, Miguel
2
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I need to absolutely minimize the number of round-trip requests for a page on my site (because mobile phones will also be accessing it). I want to include some global styles for all the pages of my...
10
by: olivier.scalbert | last post by:
Hello, the following constraints: source: <Source> <Item>AAA</Item> <Item>BBBBBBBBBBB</Item> <Item>CCCCCCCCC</Item> <Item>DDDDDDDDDDDDDDD</Item>
3
by: xq386 | last post by:
Question: In the XSL file below I put a part of the code (concerning the euro-sign) in comment. If I remove the comment then it doesn't work anymore. How can this be solved? I run Test.html with...
6
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I want to insert a CSS Stylesheet file in a <LINKtag inside my MasterPage so that it will work in all of the the ASPX pages that use that MasterPage (no matter where the page is in the directory...
2
by: Gandalf | last post by:
Whay when I use this HTML element: <link type='text/css' rel='StyleSheet' href='images/style.php'> And even after I define the right header at the style.php file: <?php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.