|
 |
aspx_beginners thread: Applying a Stylesheet to the Whole Application
Message #1 by kristin@c... on Fri, 27 Sep 2002 21:15:22
|
|
Is there a way to apply a stylesheet to all the pages in an ASP.NET
project? I don't want to manually add <link REL="stylesheet"
TYPE="text/css" HREF="styles.css"> to every page.
Thanks -- Kristin
Message #2 by Imar Spaanjaars <Imar@S...> on Fri, 27 Sep 2002 22:33:04 +0200
|
|
I don't think so.
What I usually do to create some sort of behavior like that, is to add a
User Control to every page. This would still force you to add something to
every page, but it allows you to change stuff in just one place. In its
simplest form, a User Control is just an ASPX page, but with an ASCX extension.
Here's a small example:
incHead.ascx
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="incHead.ascx.vb" Inherits="MyNamespace.incHead"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<script language="JavaScript" type="text/javascript"
src="/scripts/browserSniffer.js" />
<script language="JavaScript" type="text/javascript">
if (!is_ie5up)
{
top.location.href='/tools/wrongBrowser.asp';
}
</script>
<link rel="stylesheet" type="text/css"
href="/styles/<%=Request.Cookies("FORMULA").Value %>/mainStyle.css" />
This is a sample header that gets applied to every page that uses the
incHead user control. In my example, it's a part of a simple <head>
section, that defines some JavaScript to filter any non IE5 or up browser
out (corporate Intranet) and defines a stylesheet.
To use it in your page, you need to make two additions:
1. Put this on top of every page:
<%@ Register TagPrefix="MyTagPrefix" TagName="incHead" Src="/incHead.ascx" %>
2. In the <head> section of your page:
<MyTagPrefix:inchead id="IncHead1"
runat="server"></MyTagPrefix:inchead>
Another solution is to use Dreamweaver's templates. It''s tool specific but
it works great.
HtH,
Imar
At 09:15 PM 9/27/2002 +0000, you wrote:
>Is there a way to apply a stylesheet to all the pages in an ASP.NET
>project? I don't want to manually add <link REL="stylesheet"
>TYPE="text/css" HREF="styles.css"> to every page.
>
>Thanks -- Kristin
Message #3 by kristin@c... on Fri, 27 Sep 2002 22:33:11
|
|
Thank you Imar. That worked beautifully, and now I can create other user
controls to simplify my page development.
Kristin
|
|
 |