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

Dynamically add Style Link to header of html

Hi all

Is there a way to add a LINK rel="stylesheet" href="StyleSheet1.css"
type="text/css" tag to the header of each page at run time, rather than
having to copy and paste it into the html view of every new form as we create
them?

I would use a base page probably, just not sure how to add the code and get
it into the header section of the outgoing html

Thanks
Jeff
Jan 1 '07 #1
2 4130
if you are using .net 2 you can use the Page.Headers collection.
Jan 2 '07 #2
Hi,

In 2.0 you can use Master Pages:

ASP.NET Master Pages Overview
http://msdn2.microsoft.com/en-us/library/wtxbf3hh.aspx

In previous framework versions add a runat=server attribute in the head tag:

<head runat="server" id="header"></head>

You can add a literal control in the code-behind:

private HtmlGenericControl header;

void Page_Load(object sender, EventArgs e)
{
header.Controls.Add(new LiteralControl(@"
<link rel=""stylesheet"" type=""text/css"" src=""" + cs1+ @""">
<link rel=""stylesheet"" type=""text/css"" src=""" + cs2 + @""">"
));
}

(Note: I didn't test the code so watch for typos)

--
Dave Sexton
http://davesexton.com/blog

"jeff31162" <je*******@discussions.microsoft.comwrote in message
news:22**********************************@microsof t.com...
Hi all

Is there a way to add a LINK rel="stylesheet" href="StyleSheet1.css"
type="text/css" tag to the header of each page at run time, rather than
having to copy and paste it into the html view of every new form as we
create
them?

I would use a base page probably, just not sure how to add the code and
get
it into the header section of the outgoing html

Thanks
Jeff

Jan 2 '07 #3

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

Similar topics

2
by: wjbell | last post by:
I have a piece of javascript I need to modify. Right now it changes a stylesheet in the document between style.css and no_indent.css. These are in the head of my document: <link rel=stylesheet...
7
by: Just Dummy | last post by:
Hi all, I am struggling with a problem for a long time. Problem statement: I have a table and the table can contain n number of rows. i.e., the table rows will be generataed out of a xml...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
2
by: Axel Dahmen | last post by:
HI, I want to dynamically add controls to a web page from within a common base class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The Controls collection cannot be modified...
1
by: Amanda H. | last post by:
I posted about this a few days ago, and I got a few suggestions that fixed part of my problem. I am using a PHP script to switch external style sheets when the viewer clicks on the style link. ...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
6
by: _Who | last post by:
I use the code below to change to a style sheet that has: body { ....
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.