Hi,
I've a a site with nested master pages and content pages. I tried using
a theme with a stylesheet in the app_themes directory referencing it in
the web.config file from a pages tag theme attribute. This works for
the content pages, but it doesn't seem able to apply the styles to the
top master page even though I did set the master head tag to runat
server. Is this by design? If so, what is the best way to apply styles
to the top master page content? What did work for me was to add a style
sheet link in the master page header but this doesn't seem to be a very
elegant solution to me; my goal is to have site wide styles applied to
all masters and content pages from a single stylesheet. Is applying
styles to the header programatically from the content pages code behind
a better answer? If so, an example would be much appreciated!
Thanks for any help on this! 7 3494
Hi,
to dynamically add a stylesheet from a MasterPage, use the following
code inside the OnLoad for instance:
HtmlLink link = new HtmlLink();
link.Href = "MyStylesheet.c ss"
link.Attributes .Add(HtmlTextWr iterAttribute.R el.ToString()," stylesheet");
Page.Header.Con trols.Add(link) ;
Your other questions I do not know about.
Grtz, Wouter
The master and the page get merged and rendered as a single page into the
browser, so I'm not sure why using a CSS from App_Themes isn't working for
you -- try looking at the rendered HTML source and perhaps there's something
wrong with the CSS class you're using in the master?
-Brock
DevelopMentor http://staff.develop.com/ballen Hi,
I've a a site with nested master pages and content pages. I tried using a theme with a stylesheet in the app_themes directory referencing it in the web.config file from a pages tag theme attribute. This works for the content pages, but it doesn't seem able to apply the styles to the top master page even though I did set the master head tag to runat server. Is this by design? If so, what is the best way to apply styles to the top master page content? What did work for me was to add a style sheet link in the master page header but this doesn't seem to be a very elegant solution to me; my goal is to have site wide styles applied to all masters and content pages from a single stylesheet. Is applying styles to the header programatically from the content pages code behind a better answer? If so, an example would be much appreciated!
Thanks for any help on this!
Here's a cleaner (to read) implementation ...
protected void Page_Init(objec t sender, EventArgs e)
{
// Your comments here...
HtmlLink link = new HtmlLink();
link.Href = "~/StyleSheet.css" ;
link.Attributes .Add("rel", "stylesheet ");
link.Attributes .Add("type", "text/css");
Page.Header.Con trols.Add(link) ;
}
Note the use of Page_Init emits the declaration 'before' the stylesheet
declaration generated by the Theme. If you want or need a stylesheet to
over-ride styles used by the Theme put the code shown above into the
Page_Load event.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee. com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Wouter van Vugt" <wo*****@infosu pport.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com... Hi,
to dynamically add a stylesheet from a MasterPage, use the following code inside the OnLoad for instance:
HtmlLink link = new HtmlLink(); link.Href = "MyStylesheet.c ss" link.Attributes .Add(HtmlTextWr iterAttribute.R el.ToString()," stylesheet"); Page.Header.Con trols.Add(link) ;
Your other questions I do not know about. Grtz, Wouter
I got started writing all of my style declarations in the theme.css file
located in the App_Themes folders. One great big collection of declarations
in a single file. A bad habit it seems and perhaps a misunderstandin g of how
other aspects of Themes actually work because using a monolithic file
provides no mechanism for browser dependent styles so I became motivated to
write a separate style sheet into the head element.
<%= Clinton Gallagher
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:b8******** *************** ***@msnews.micr osoft.com... The master and the page get merged and rendered as a single page into the browser, so I'm not sure why using a CSS from App_Themes isn't working for you -- try looking at the rendered HTML source and perhaps there's something wrong with the CSS class you're using in the master?
-Brock DevelopMentor http://staff.develop.com/ballen
Hi,
I've a a site with nested master pages and content pages. I tried using a theme with a stylesheet in the app_themes directory referencing it in the web.config file from a pages tag theme attribute. This works for the content pages, but it doesn't seem able to apply the styles to the top master page even though I did set the master head tag to runat server. Is this by design? If so, what is the best way to apply styles to the top master page content? What did work for me was to add a style sheet link in the master page header but this doesn't seem to be a very elegant solution to me; my goal is to have site wide styles applied to all masters and content pages from a single stylesheet. Is applying styles to the header programatically from the content pages code behind a better answer? If so, an example would be much appreciated!
Thanks for any help on this!
Unfortunately, that throws an error for me at :
Page.Header.Con trols.Add(link) ;
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Here's a cleaner (to read) implementation ...
protected void Page_Init(objec t sender, EventArgs e) { // Your comments here... HtmlLink link = new HtmlLink(); link.Href = "~/StyleSheet.css" ; link.Attributes .Add("rel", "stylesheet "); link.Attributes .Add("type", "text/css"); Page.Header.Con trols.Add(link) ; }
Note the use of Page_Init emits the declaration 'before' the stylesheet declaration generated by the Theme. If you want or need a stylesheet to over-ride styles used by the Theme put the code shown above into the Page_Load event.
<%= Clinton Gallagher METROmilwaukee (sm) "A Regional Information Service" NET csgallagher AT metromilwaukee. com URL http://metromilwaukee.com/ URL http://clintongallagher.metromilwaukee.com/ "Wouter van Vugt" <wo*****@infosu pport.com> wrote in message news:11******** *************@z 14g2000cwz.goog legroups.com... Hi,
to dynamically add a stylesheet from a MasterPage, use the following code inside the OnLoad for instance:
HtmlLink link = new HtmlLink(); link.Href = "MyStylesheet.c ss" link.Attributes .Add(HtmlTextWr iterAttribute.R el.ToString()," stylesheet"); Page.Header.Con trols.Add(link) ;
Your other questions I do not know about. Grtz, Wouter
On Mon, 21 Nov 2005 13:52:05 -0400, "Juan T. Llibre"
<no***********@ nowhere.com> wrote: Unfortunatel y, that throws an error for me at :
Page.Header.Co ntrols.Add(link );
I have a guess at what is happening:
You'll need a <head> element with runat="server", otherwise you'll see
a NullReferenceEx ception.
--
Scott http://www.OdeToCode.com/blogs/scott/
You nailed that one, Scott.
Thanks.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:56******** *************** *********@4ax.c om... On Mon, 21 Nov 2005 13:52:05 -0400, "Juan T. Llibre" <no***********@ nowhere.com> wrote:
Unfortunately , that throws an error for me at :
Page.Header.C ontrols.Add(lin k);
I have a guess at what is happening:
You'll need a <head> element with runat="server", otherwise you'll see a NullReferenceEx ception. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jan Roland Eriksson |
last post by:
Archive-name: www/stylesheets/authoring-faq
Posting-Frequency: twice a week (Mondays and Thursdays)
Last-modified: August 28, 2002
Version: 1.15
URL: http://css.nu/faq/ciwas-aFAQ.html
Maintainer: Jan Roland Eriksson <rex@css.nu>
ciwas stylesheet authoring FAQ v1.15
______________________________________________________________________
|
by: Jamie |
last post by:
Hi,
Thanks for the excellent answer to my last question! One more:
Does anyone have a method they follow for organizing stylesheets
themselves? They seem like they can get bloated and hard to read. Aside
from putting all the "h1" rules together, I haven't thought of any way
to do it, if it's necessary at all.
J.
|
by: Jan Roland Eriksson |
last post by:
Archive-name: www/stylesheets/authoring-faq
Posting-Frequency: twice a week (Mondays and Thursdays)
Last-modified: April 10, 2003
Version: 1.16
URL: http://css.nu/faq/ciwas-aFAQ.html
Maintainer: Jan Roland Eriksson <rex@css.nu>
ciwas stylesheet authoring FAQ v1.16
______________________________________________________________________
|
by: sasquatch |
last post by:
Hi,
I've a a site with nested master pages and content pages. I tried using
a theme with a stylesheet in the app_themes directory referencing it in
the web.config file from a pages tag theme attribute. This works for
the content pages, but it doesn't seem able to apply the styles to the
top master page even though I did set the master head tag to runat
server. Is this by design? If so, what is the best way to apply styles
to the top...
|
by: SR |
last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all
of my classes in a StyleSheet but I cannot figure out how to link the
StyleSheet to a Content Page since there is no header. I tried to put the
link tag in the Master page, but the classes are not recognized in the
Content Page.
How do I use a StyleSheet with the Content Page?
TIA
| |
by: Jeff |
last post by:
ASP.NET 2.0
I have problem with the markup and skin file below, this table isn't
displayed.
webpage
<asp:Table ID="compose" SkinID="compose" runat="server">
<asp:TableRow>
<asp:TableCell SkinID="recipient">fffff</asp:TableCell>
</asp:TableRow>
|
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= |
last post by:
I want to insert a CSS Stylesheet file in a <LINKtag inside my MasterPage
so that it will work in all of the the ASPX pages that use that MasterPage
(no matter where the page is in the directory hierarchy).
I tried adding
<link type="text/css" rel="stylesheet"
href="~/Shared/CSS/Standard.css" runat="server" />
in the <headsection of the MasterPage. When I look at the source of my
pages later when I'm running it, it *does* seem to...
|
by: Guillaume Dargaud |
last post by:
Hello all,
I have a strange problem with a new install of Gallery2: Firefox does not
display the style of the pages while IE does (but nobody I know uses IE).
I'm not familiar with the way Gallery2 generates its pages but my config
uses Apache (on Windows), php5, MySQL, etc... There are several themes
available in Gallery2 but none display in FF. It's like the CSS is ignored.
The pages I get in the browser contain the following CSS...
|
by: Mort Strom |
last post by:
Right now the header of my master page contains all of the CSS styles for
all of the pages that might be loaded in my ContentPlaceHolder. The problem
is that my <styletag is getting too large to manage. I have 300 lines of
styles in my masterpage and I don't need all of this for every page --
somehow this can't be a smart way of managing styles.
How do I programmatically apply styles in my MasterPage based on the
ContentPlaceHolder...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |