Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.Net selecting a stylesheet based on a variable

Posted on 2013-12-17
2
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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