Dynamic style sheet link.

  • Thread starter Thread starter David W
  • Start date Start date
D

David W

I need to include a style sheet link in the aspx page based on what user
they are.

Basically this functionality, but using code behind. Any idea how to change
this line to code behind? This breaks once we include an AJAX control on
the page.

<head runat="server">
<link href="/textfiles/style<%= Session("partner_id") %>.css"
rel="stylesheet" type="text/css">
</head>

Thanks.
 
Give HEAD an ID. Assuming it is m_Head then your codebehind would look
something like:

m_Head.Controls.Add(new Literal("<link .... >"));

note: I didn't check syntax exactly but you should get the jist.

-----Original Message-----
From: David W [mailto:[email protected]]
Posted At: Tuesday, October 30, 2007 12:46 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Dynamic style sheet link.
Subject: Dynamic style sheet link.

I need to include a style sheet link in the aspx page based on what user

they are.

Basically this functionality, but using code behind. Any idea how to
change
this line to code behind? This breaks once we include an AJAX control
on
the page.

<head runat="server">
<link href="/textfiles/style<%= Session("partner_id") %>.css"
rel="stylesheet" type="text/css">
</head>

Thanks.
 
Thanks. Literals don't take a constructor, but I get the point. Also found
out you can reference the head through the Header property.

Dim lit As New Literal()
lit.Text = "<link href=""/textfiles/style" & Session("partner_id") & ".css""
rel=""stylesheet"" type=""text/css"">"
Me.Header.Controls.Add(lit)
 
Back
Top