473,394 Members | 1,797 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.

Master Pages - CSS

When using master pages, how can I get an external style sheet applied to
the specific page and still see the effects at design time. I want to have a
generic style sheet and specific ones for each page.

The only way I can think to do this is to put a link tag in the master with
a specific ID but leave the source blank. When the page loads it gets the
tag from the master and then adds the src attribute, the problem is that you
cannot see the effects of the style changes at design time.

Can someon offer a solution,
Feb 10 '07 #1
6 4152
Just Me schrieb:
When using master pages, how can I get an external style sheet applied to
the specific page and still see the effects at design time. I want to have a
generic style sheet and specific ones for each page.

The only way I can think to do this is to put a link tag in the master with
a specific ID but leave the source blank. When the page loads it gets the
tag from the master and then adds the src attribute, the problem is that you
cannot see the effects of the style changes at design time.

Can someon offer a solution,
<code>
Dim cssLink As New HtmlLink()
cssLink.Href = "~/styles.css"
cssLink.Attributes.Add("rel", "stylesheet")
cssLink.Attributes.Add("type", "text/css")
Header.Controls.Add(cssLink)
</code>

greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.
Feb 10 '07 #2
Im afraid I cannot get this to work, it says it cannot be done in content
pages

"Stefan Kalcher" <st************@dolphicom.atwrote in message
news:18***************************@news.inode.at.. .
Just Me schrieb:
>When using master pages, how can I get an external style sheet applied to
the specific page and still see the effects at design time. I want to
have a
generic style sheet and specific ones for each page.

The only way I can think to do this is to put a link tag in the master
with
a specific ID but leave the source blank. When the page loads it gets the
tag from the master and then adds the src attribute, the problem is that
you
cannot see the effects of the style changes at design time.

Can someon offer a solution,

<code>
Dim cssLink As New HtmlLink()
cssLink.Href = "~/styles.css"
cssLink.Attributes.Add("rel", "stylesheet")
cssLink.Attributes.Add("type", "text/css")
Header.Controls.Add(cssLink)
</code>

greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.

Feb 10 '07 #3
The head tag in the master page must include runat="server" for the
Header property to work.

Just Me schrieb:
Im afraid I cannot get this to work, it says it cannot be done in content
pages
><code>
Dim cssLink As New HtmlLink()
cssLink.Href = "~/styles.css"
cssLink.Attributes.Add("rel", "stylesheet")
cssLink.Attributes.Add("type", "text/css")
Header.Controls.Add(cssLink)
</code>
greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.
Feb 10 '07 #4
If you don't want the head-tag to be that ugly formatted in the
resulting html-code like it is with runat="server" attached, you could
use <asp:literal/and access its Text-property via a public property in
the Master-Page.

Could look something like this:

Expand|Select|Wrap|Line Numbers
  1. Public Property adiCSS as string
  2. Get
  3. Return litAditionalStylesheet.Text
  4. End Get
  5. Set
  6. litAditionalStylesheet.Text = Value
  7. End Set
  8. End Property
  9.  
And the Client-Page:

Expand|Select|Wrap|Line Numbers
  1. Master.adiCSS = "<link href=""/images/add.css"" title=""whatever""" & _
  2. "rel=""stylesheet"" type=""text/css"" media=""screen""/>"
  3.  
Just Me schrieb:
Im afraid I cannot get this to work, it says it cannot be done in content
pages
greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.
Feb 10 '07 #5
I found Aanother way. If you create a themes directory, you can add the
style sheets in there and then add them into the page directive.

Thanks for your help

"Stefan Kalcher" <st************@dolphicom.atwrote in message
news:e4***************************@news.inode.at.. .
If you don't want the head-tag to be that ugly formatted in the
resulting html-code like it is with runat="server" attached, you could
use <asp:literal/and access its Text-property via a public property in
the Master-Page.

Could look something like this:

Expand|Select|Wrap|Line Numbers
  1. Public Property adiCSS as string
  2. Get
  3. Return litAditionalStylesheet.Text
  4. End Get
  5. Set
  6. litAditionalStylesheet.Text = Value
  7. End Set
  8. End Property
  9.  

And the Client-Page:

Expand|Select|Wrap|Line Numbers
  1. Master.adiCSS = "<link href=""/images/add.css"" title=""whatever""" & _
  2. "rel=""stylesheet"" type=""text/css"" media=""screen""/>"
  3.  

Just Me schrieb:
>Im afraid I cannot get this to work, it says it cannot be done in content
pages

greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.

Feb 10 '07 #6
None of the suggestions actually answered how to support a different linked
stylesheet for each page that is supposed to be loaded. I'll touch on that
briefly noting there's many methodologies to generate stylesheet
declarations when the compiler is building the page.

Using Themes for example has also turned out to be quite complex and
convoluted with regard to the use of .css files. Make sure the difference
between a Theme and a StyleSheetTheme is well understood.

And... when using MasterPages with one or more Themes or StyleSheetThemes we
are compelled to use a base class that all pages inherit from. This enables
the Page_PreInit in the base class to be used to enable code to be used to
determine which page is being loaded so a certain Theme or stylesheet can
also be loaded. The .master does not support the Page_PreInit event.

K. Scott Allen's work explaining must be consulted [1]. Google's site:
filter is best used to find specific documentation at msdn2 where the latest
documentation is found.

// example
master pages overview site:msdn2.microsoft.com
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP http://wikimapia.org/#y=43038073&x=-...8&z=17&l=0&m=h

[1] http://odetocode.com/


"Just Me" <news.microsoft.comwrote in message
news:u0****************@TK2MSFTNGP03.phx.gbl...
>I found Aanother way. If you create a themes directory, you can add the
style sheets in there and then add them into the page directive.

Thanks for your help

"Stefan Kalcher" <st************@dolphicom.atwrote in message
news:e4***************************@news.inode.at.. .
>If you don't want the head-tag to be that ugly formatted in the
resulting html-code like it is with runat="server" attached, you could
use <asp:literal/and access its Text-property via a public property in
the Master-Page.

Could look something like this:

Expand|Select|Wrap|Line Numbers
  1. Public Property adiCSS as string
  2. Get
  3. Return litAditionalStylesheet.Text
  4. End Get
  5. Set
  6. litAditionalStylesheet.Text = Value
  7. End Set
  8. End Property

And the Client-Page:

Expand|Select|Wrap|Line Numbers
  1. Master.adiCSS = "<link href=""/images/add.css"" title=""whatever""" & _
  2. "rel=""stylesheet"" type=""text/css"" media=""screen""/>"

Just Me schrieb:
>>Im afraid I cannot get this to work, it says it cannot be done in
content
pages

greets,
Stefan

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.


Feb 12 '07 #7

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: 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
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
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.