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

Master Pages and CSS

Hello,

I have created a master page with a css.

How can I use css in the children pages? The css must be declared in the
<head</headsection. Does I have to import all my css in my master?
Is there a way to import only one css for one children page?

Thanks a lot.

Mike.
Nov 2 '06 #1
4 2347
Your content placeholders at delivery become part of the page delivered,
which includes your CSS. AS long as you reference the CSS class ID's in
your controls and output the css should be picked up.

If you wish to change the CSS entirely based on which contentplaceholder is
loaded then you can do that in the page load event of the placeholder.

<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server" />
</head>

Sub Page_Load(Sender As Object, E As EventArgs)
If Not (IsPostBack)
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
End If
End Sub

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

"Mikaël PLOUHINEC" <mi**@cerealog.frwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
Hello,

I have created a master page with a css.

How can I use css in the children pages? The css must be declared in the
<head</headsection. Does I have to import all my css in my master? Is
there a way to import only one css for one children page?

Thanks a lot.

Mike.

Nov 2 '06 #2
I'm sorry but I'm not sure I understand what you tell me.

Your
<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server" />
</head>

is in the master page isn't it?

So you tell me that I have to add my css with
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
in the page_load of my children page, no?

Maybe I don't think correctly about my problem.

I have several web pages which the header and the left menu are
identical. So I would like to use master page (I think it is a good way
to do that). I have created a master page and a css (only for the master
page elements).
Moreover, the content placeholders of my childrens pages have to be
constructed with a different css for all my childrens pages (on page =
one css).

Does your method answer to my question?

Thanks a lot for your help.

Mike.

John Timney (MVP) a écrit :
Your content placeholders at delivery become part of the page delivered,
which includes your CSS. AS long as you reference the CSS class ID's in
your controls and output the css should be picked up.

If you wish to change the CSS entirely based on which contentplaceholder is
loaded then you can do that in the page load event of the placeholder.

<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server" />
</head>

Sub Page_Load(Sender As Object, E As EventArgs)
If Not (IsPostBack)
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
End If
End Sub

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

"Mikaël PLOUHINEC" <mi**@cerealog.frwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
>Hello,

I have created a master page with a css.

How can I use css in the children pages? The css must be declared in the
<head</headsection. Does I have to import all my css in my master? Is
there a way to import only one css for one children page?

Thanks a lot.

Mike.

Nov 2 '06 #3
I'm sorry but I'm not sure I understand what you tell me.
Your
<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server"
/>
</head>

is in the master page isn't it?
Yes, but you could also have a common stylesheet link to a top level
stylesheet along with this containing your master page CSS code only
So you tell me that I have to add my css with
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
in the page_load of my children page, no?
yes, if you want to seperate and only load your child CSS in the placeholder
load event.
Maybe I don't think correctly about my problem.

I have several web pages which the header and the left menu are identical.
So I would like to use master page (I think it is a good way to do that).
I have created a master page and a css (only for the master page
elements).
You should add all CSS elements to your master where possible
Moreover, the content placeholders of my childrens pages have to be
constructed with a different css for all my childrens pages (on page = one
css).
.........thats what the code I sent allows you to do....load the css file
only at child load

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

John Timney (MVP) a écrit :
>Your content placeholders at delivery become part of the page delivered,
which includes your CSS. AS long as you reference the CSS class ID's in
your controls and output the css should be picked up.

If you wish to change the CSS entirely based on which contentplaceholder
is loaded then you can do that in the page load event of the placeholder.

<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server"
/>
</head>

Sub Page_Load(Sender As Object, E As EventArgs)
If Not (IsPostBack)
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
End If
End Sub

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

"Mikaël PLOUHINEC" <mi**@cerealog.frwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
>>Hello,

I have created a master page with a css.

How can I use css in the children pages? The css must be declared in the
<head</headsection. Does I have to import all my css in my master?
Is there a way to import only one css for one children page?

Thanks a lot.

Mike.

Nov 2 '06 #4
Ok.

Thanks a lot for your answers.

Mike
John Timney (MVP) a écrit :
>I'm sorry but I'm not sure I understand what you tell me.

>Your
<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server"
/>
</head>

is in the master page isn't it?

Yes, but you could also have a common stylesheet link to a top level
stylesheet along with this containing your master page CSS code only

>So you tell me that I have to add my css with
cssStyleSheet.Attributes.Add("href","Stylesheet1. css")
in the page_load of my children page, no?

yes, if you want to seperate and only load your child CSS in the placeholder
load event.

>Maybe I don't think correctly about my problem.

I have several web pages which the header and the left menu are identical.
So I would like to use master page (I think it is a good way to do that).
I have created a master page and a css (only for the master page
elements).

You should add all CSS elements to your master where possible

>Moreover, the content placeholders of my childrens pages have to be
constructed with a different css for all my childrens pages (on page = one
css).

........thats what the code I sent allows you to do....load the css file
only at child load

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
>John Timney (MVP) a écrit :
>>Your content placeholders at delivery become part of the page delivered,
which includes your CSS. AS long as you reference the CSS class ID's in
your controls and output the css should be picked up.

If you wish to change the CSS entirely based on which contentplaceholder
is loaded then you can do that in the page load event of the placeholder.

<head>
<link id="cssStyleSheet" rel="stylesheet" type="text/css" runat="server"
/>
</head>

Sub Page_Load(Sender As Object, E As EventArgs)
If Not (IsPostBack)
cssStyleSheet.Attributes.Add("href","Stylesheet1.c ss")
End If
End Sub

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

"Mikaël PLOUHINEC" <mi**@cerealog.frwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...

Hello,

I have created a master page with a css.

How can I use css in the children pages? The css must be declared in the
<head</headsection. Does I have to import all my css in my master?
Is there a way to import only one css for one children page?

Thanks a lot.

Mike.


Nov 2 '06 #5

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

Similar topics

1
by: Sasha | last post by:
Hi all asp.net proffesionals out there, How do you implement master pages in your applications? What libraries do you use and what have been your experience? Sasha
5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
3
by: Rich | last post by:
Hi, I want to use 2 master pages, one for the main part of the site, the other for the admin pages. They are quite similar, with many shared elements. Ideally I would like to have a parent...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
6
by: Mickey | last post by:
Coming from a Dreamweaver/ASP/PHP background. Planning to use Visual Studio 2008 for a website. Complete newbie question here (please be gentle!): Do master pages work similar to Dreamweaver...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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,...

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.