473,405 Members | 2,349 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,405 software developers and data experts.

I need my CSS in the master page to get reflected in content page

Hi,

I have one master page which has some table inside one of the <td> i
have my contentplaceholder.

on the <head> tag of the master page i have specified link to a global
CSS (stylesheet.css) file.

On my content page i have a textbox inside the contentplaceholder.

What i want is my all content page to use the same CSS file
(stylesheet.css).

If i specify on the page load

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

It works fine.

But this i will have to include in all my content pages, so if in case
if i want any other stylesheet file to be global, i will have to modify
code in all my content pages.

Can anybody suggest how can i specify a css file in master and inherit
that in all my content pages.

Thnx
Pushpadant

Jun 29 '06 #1
7 6519
why don't you just declare the style sheet in the head section of the
master page?

....
<head>
<LINK href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
....

pu********@gmail.com wrote:
Hi,

I have one master page which has some table inside one of the <td> i
have my contentplaceholder.

on the <head> tag of the master page i have specified link to a global
CSS (stylesheet.css) file.

On my content page i have a textbox inside the contentplaceholder.

What i want is my all content page to use the same CSS file
(stylesheet.css).

If i specify on the page load

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

It works fine.

But this i will have to include in all my content pages, so if in case
if i want any other stylesheet file to be global, i will have to modify
code in all my content pages.

Can anybody suggest how can i specify a css file in master and inherit
that in all my content pages.

Thnx
Pushpadant


Jun 29 '06 #2
Neil wrote the way to do what you want but if your pages will be in
subfolders in your app you need to get the relative path of the css file:

<LINK href="<%=ResoveUrl("~stylesheet.css%>" rel="stylesheet"
type="text/css">

You can add page_load event in your master page too and make the link on
the fly.

ne**********@gmail.com wrote:
why don't you just declare the style sheet in the head section of the
master page?

...
<head>
<LINK href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
...

pu********@gmail.com wrote:
Hi,

I have one master page which has some table inside one of the <td> i
have my contentplaceholder.

on the <head> tag of the master page i have specified link to a global
CSS (stylesheet.css) file.

On my content page i have a textbox inside the contentplaceholder.

What i want is my all content page to use the same CSS file
(stylesheet.css).

If i specify on the page load

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

It works fine.

But this i will have to include in all my content pages, so if in case
if i want any other stylesheet file to be global, i will have to modify
code in all my content pages.

Can anybody suggest how can i specify a css file in master and inherit
that in all my content pages.

Thnx
Pushpadant

Jun 29 '06 #3
I have put the following in the master page

<head>
<LINK href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
But it will not reflect on the content page, because only the contents
in the
<asp:contentplaceholder
will be inherited on the content pages,

what now i do is add in the content page:

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

but this i will have to write in all the content pages, is there any
way to avoid this code replication.

somehow content page cud get the link from Master page

Jun 30 '06 #4

I have created a common class, it has a func addCSS(htmlheader header),
now i call this function from all my pages passing header of the page
as parameter..

I this case if i want to use some other css page, will have to change
only at one place in the class.

Thnx for ur reponses.

Pushpadant

Jun 30 '06 #5
wrong. look at the resultant HTML source. you will see your style sheet
reference in there, with the way i proposed.

cheers

neil
Pushpadant wrote:
I have created a common class, it has a func addCSS(htmlheader header),
now i call this function from all my pages passing header of the page
as parameter..

I this case if i want to use some other css page, will have to change
only at one place in the class.

Thnx for ur reponses.

Pushpadant


Jun 30 '06 #6
In article <11**********************@75g2000cwc.googlegroups. com>,
pu********@gmail.com writes
<snip>
>Can anybody suggest how can i specify a css file in master and inherit
that in all my content pages.
Well, apart from the ways that others have suggested, which should all
work and be a lot easier than the way you have suggested, you could look
at using themes. If you specify a theme, and put the CSS file in the
appropriate theme folder, then the framework will include it in every
page for you. You don't need to do anything.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
Jul 2 '06 #7

@Neil..

You were absolutely right...i tried ur method at the very
begining.....but it did not work....that was the only reason i
posted...but now it did seem to wrk....
i really cant guess y....
will try using theme some time later after i've got a working model.

Thnx for the help....

Jul 3 '06 #8

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

Similar topics

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...
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...
1
by: BigSam | last post by:
I have updated my master page to reflect some different formatting. When I open one of the pages that uses the master page, the change isn't reflected. How do I tell the child page the master has...
4
by: Learner | last post by:
Hello, Here is a little bit of what I am working ... I have selected Header and Side lay out for my Master Page. All my links go on the Side and the content on to the right pane. I have no...
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...
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
2
by: Stratum | last post by:
It's an old question, and I apologize for raising it again. I use ImageButton objects on my ASP.Net master page to navigate to content pages. For each button, I have two images. One image shows...
5
by: =?Utf-8?B?QW50?= | last post by:
Hi, I'm a newbie to the Master page. When i drag an image directly onto the master page from say my image folder, it is reflected in all pages which use it, however, if I drag a table, layout,...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.