Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:27:18+00:00 2026-05-25T13:27:18+00:00

I am implementing a web application using ASP.NET MVC3. In the application I want

  • 0

I am implementing a web application using ASP.NET MVC3. In the application I want to add the option of switching between CSS files (for themes) based on clicking some links. I did some research and I came up with the following:

  1. To pass data to site.master, the good solution is to create an abstract controller and inherit that into the other controllers that have site.master as their template, according to this article: Passing Data to View Master Pages
  2. I can pass a viewbag message to the link which controls the css file URL to set the current css file to use, based on the code that I am seeing being passed to scripts at the top of the site.master page:

script src=”<%: Url.Content(“~/Scripts/jquery-1.5.1.min.js”) %>” type=”text/javascript”

So I created an abstract controller, ApplicationController, with the following method:

public ApplicationController()
    {ViewBag.NewMessage = "../../Content/Site2.css";}

And in the site.master, I included this link:

<link href="<%: (string) ViewBag.NewMessage %>" rel="stylesheet" type="text/css" />

However, that doesn’t seem to be working, as it is being interpreted as:

<link href="&lt;%: (string) ViewBag.NewMessage %>" rel="stylesheet" type="text/css" />

And only when I remove the quotation marks:

<link href=<%: (string) ViewBag.NewMessage %> rel="stylesheet" type="text/css" />

is it being interpreted correctly (and the webpage gets rendered with the correct css), except that it violates html standards:

<link href=../../Content/Site2.css rel="stylesheet" type="text/css" />

Any suggestion about how to go tackling this problem or is there a more elegant solution I’m missing? I was going to proceed and implement variables in the ApplicationController that get selected based on links the user clicks at the top of the page, to switch between css styles.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:27:18+00:00Added an answer on May 25, 2026 at 1:27 pm

    Check to make sure your <head> tag does not have runat="server".

    After making this change, be sure to check your script and css tags. This change can break the paths if you use the ~/ to ref app root. To help with this, use the Url.Content(...) helper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried implementing a simple web service into an asp.net application using the tutorial
I am refactoring a working ASP.NET Web Application to expose Web Services interface using
I ran into this dilemma when working on an ASP.net web application using Web
I an developing a web application in ASP.Net using C#, under .Net Framework 4.0.
I want to build a webapplication with a Single Page Interface, using ASP.NET MVC.
I am building a web based application written in ASP.NET and Flex. One of
I'm implementing a little web application using Java and the Wicket framework. Each user
I have some .aspx pages in my asp.net web application which only admin can
I am implementing COMET in my MVC web application by using the PokiIn library
I have a question about precompiling ASP.NET web application projects from TeamCity. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.