Dynamic style sheet link.

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

Dave Bush

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

David W

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top