ASP.Net selecting a stylesheet based on a variable

Hi,

I have an ASP.Net website with a masterpage containing the following line in its head:

<link href="/Style/base.css" rel="stylesheet" type="text/css" />

There is also a variable called SiteId which is assigned a value in Sub Page_Init

Now, instead of picking the base.css file in the /Style directory, I want to pick up base.css in /Style/<SiteId>

I have tried:

<link href="/Style/<%= SiteId %>/base.css" rel="stylesheet" type="text/css" />

but this doesn't work.

How do I do this?

Thanks,

Richard
LVL 1
rpmAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Kamal KhaleefaConnect With a Mentor Information Security SpecialistCommented:
you can add runat="server" to your style and control it from code behind

see this link
http://rodrigueh.com/dynamically-change-css
0
 
Luis PérezSoftware Architect in .NetCommented:
Your code should work. How is the variable declared? Try declaring it protected into your page.

Hope that helps.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.