473,804 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4172
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.Attribu tes.Add("rel", "stylesheet ")
cssLink.Attribu tes.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.atwr ote 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.Attribu tes.Add("rel", "stylesheet ")
cssLink.Attribu tes.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.Attrib utes.Add("rel", "stylesheet ")
cssLink.Attrib utes.Add("type" , "text/css")
Header.Control s.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.atwr ote 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 StyleSheetTheme s 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.micr osoft.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******** ********@TK2MSF TNGP03.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.atwr ote 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
1628
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
2447
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 web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the Master Page? ....Content Page? ...elsewhere?
20
2430
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 include files to change the layout. When I came to ASP.NET, I used user controls to do a similar thing. I have just been looking at master pages, and it looks like they do the same thing. If so, is there any advantage in using them over the...
1
1875
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 master page looks like this... <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
17
3165
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 pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
7
8733
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 remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
8
6703
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 and also my first true attempt at using master pages. I tried setting up a style sheet with a simple setting to float an image to the right and it had no effect on the image. Then, I tried putting the style code in my ASPX file as such,
3
5977
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 master page, which both of these child master pages are based on, and in turn the final pages are based on one of these child master pages.
13
5319
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 (called "CurFlag") on my master page that can be accessed from content pages, but not from separate code modules. I tried doing something like this in my VB code module: Dim myMaster As MasterPage = CType(ProjectMgmt.Master, MasterPage)
6
1692
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 templates in that when the master page is updated, all the child pages created from the master page are updated and then they all need to be uploaded to the server? Or do you only have to upload the master page after an update?
0
9585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.