style tag in content page

D

David C

I am acclimating to ASP.NET 2.0, so excuse me not using the proper
terminology.

When I say a content page, I meant, a page that has a MasterPageFile
tag in the Page directives. So is that a slave page?

I am noticing that on that page, there is no place to put a style
tag. From what I understand what the master page does, it makes sense
since the master page has the header tag which includes all the link
tags for style sheets.

That much I understand.

But I want to be able to experiment with some CSS locally before
pushing this to the master page. But since the page does not like to
see a style tag anywhere on the page, how would you go about doing
this?
 
M

Mark Rae [MVP]

I am acclimating to ASP.NET 2.0, so excuse me not using the proper
terminology.
OK.

When I say a content page, I meant, a page that has a MasterPageFile
tag in the Page directives. So is that a slave page?

No, it's a content page.
But I want to be able to experiment with some CSS locally before
pushing this to the master page. But since the page does not like to
see a style tag anywhere on the page, how would you go about doing
this?

You would do that in the code behind your content page, probably in the
Page_Load method.

HtmlLink objLink = new HtmlLink();
objLink.Href = "MyStylesheet.css"
objLink.Attributes.Add("rel", "stylesheet")
objLink.Attributes.Add("type", "text/css")
Header.Controls.Add(objLink);

http://www.google.co.uk/search?sour...H_en-GBGB220GB220&q=MasterPage+stylesheet+add
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

David said:
I am acclimating to ASP.NET 2.0, so excuse me not using the proper
terminology.

When I say a content page, I meant, a page that has a MasterPageFile
tag in the Page directives. So is that a slave page?

I am noticing that on that page, there is no place to put a style
tag. From what I understand what the master page does, it makes sense
since the master page has the header tag which includes all the link
tags for style sheets.

That much I understand.

But I want to be able to experiment with some CSS locally before
pushing this to the master page. But since the page does not like to
see a style tag anywhere on the page, how would you go about doing
this?

You can add styles to the page with the
Page.Header.StyleSheet.CreateStyleRule method.

Example from MSDN Library:

// Create a Style object for the <BODY> section of the Web page.
Style bodyStyle = new Style();

bodyStyle.ForeColor = System.Drawing.Color.Blue;
bodyStyle.BackColor = System.Drawing.Color.LightGray;

// Add the style to the header of the current page.
Page.Header.StyleSheet.CreateStyleRule(bodyStyle, this, "BODY");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top