Solved

ASP.Net selecting a stylesheet based on a variable

Posted on 2013-12-17
2
220 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

26 Experts available now in Live!

Get 1:1 Help Now