Solved

ASP.Net selecting a stylesheet based on a variable

Posted on 2013-12-17
2
219 Views
Last Modified: 2013-12-20
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
0
Comment
Question by:rpm
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
ID: 39723581
you can add runat="server" to your style and control it from code behind

see this link
http://rodrigueh.com/dynamically-change-css
0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 39726271
Your code should work. How is the variable declared? Try declaring it protected into your page.

Hope that helps.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now