Solved

ASP.Net selecting a stylesheet based on a variable

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
why JSON Array data not binding on Model ASP.NET ? 1 43
Can Selenium do Load Testing? 2 61
.NET universe documentation poster 2 25
Javascript function 3 22
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

751 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