Solved

ASP.Net selecting a stylesheet based on a variable

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a starter for ETL protocol? 4 56
ASP.net VB.net Errors when sending data to SQL 5 20
asp day pilot 3 19
Example works but why do I need to click twice on button 4 41
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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