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

  • SEARCH
  • Home
  • 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 4104552
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:07:56+00:00 2026-05-20T21:07:56+00:00

I would like to have an option wherein a user can choose his theme

  • 0

I would like to have an option wherein a user can choose his theme for the site from the dropdown list and the theme applies to that page [atleast].

I want this to be done in ASP.NET MVC 2 without using jquery like frameworks.

How can this be accomplished.

I am using the default webforms viewengine and donot want to go for a custom viewengine for this purpose.

  • 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-20T21:07:57+00:00Added an answer on May 20, 2026 at 9:07 pm

    It seems this is not supported out of the box, but here’s what I did to implement theming:

    First, I Added the App_Themes folder to my project, and set up a couple of themesenter image description here

    I then decided to try and mimic the Web-forms profile provider as close as possible, and added a profile-property to web.config:

    <profile>
      <properties>
        <add name="ThemePreference" type="string" defaultValue="Blue" />
      </properties>
    </profile>
    

    So, basically what I wanted to do was to be able to load the different css’s from the appropriate theme-folder when the theme changed. I did this by implementing a helper method attached to the UrlHelper class so that I could write:

    <link href="@Url.Theme("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    

    This should then load the appropriate themed Site.css, and fall back to ~/Content/Site.css if no file was found.

    The helper is pretty simple:

    public static class UrlHelpers
    {
        public static string Theme(this UrlHelper url, string u)
        {
            if (u.StartsWith("~")) u = u.TrimStart('~');
            SettingsProperty settingsProperty = ProfileBase.Properties["ThemePreference"];
    
            return url.Content("~/App_Themes/"+settingsProperty.DefaultValue + u);
        }
    }
    

    Now, in this version of the code it simply gets the default-value, so you’ll need to tweak the code slightly. But as you can see, this is not limited to css-files, but works with everything from .master files to images.

    Update – Using Session instead of profile

    public static class UrlHelpers
    {
        public static string Theme(this UrlHelper url, string u)
        {
            if (u.StartsWith("~")) u = u.TrimStart('~');
    
            object currentThemeName = null;
            if (url.RequestContext.HttpContext.Session != null)
            {
                currentThemeName = url.RequestContext.HttpContext.Session["ThemePreference"];
            }
            return currentThemeName != null ? url.Content(String.Format("~/App_Themes/{0}{1}", currentThemeName, u)) : url.Content("~"+u);
        }
    }
    

    The return-line in this method checks if it found a ThemePreference session-value, and then returnes the appropriate URL for the content requested, otherwise it simply returns the content as it was requested with no App_Theme prefix.

    In your controlleraction for the DropDown postmethod, you’d simply do:

    Session.Add("ThemePreference", whateverValueYouGotFromDropdown);
    

    Update ends

    With some tweaking and fixing, this should do the trick.

    Hope it helps some, even though it’s not a complete walkthrough 🙂

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

Sidebar

Related Questions

I would like to have an option from my Application to toggle the display
Using the blog tutorial, I would like to have an option where you can
i would like to create an application that needs to have the option to
I'm creating notifications in my Android application, and would like to have an option
I would like to have a regular expression that can work in a simple
I would like to have various option to change $this_var that contain different fieldname
I would like to have the option to call Python via MySQL stored procs.
In SQL Server Reporting Services I would like to have an option to print
I would like to have an option as rename File if i select on
In a C++ program, I would like to have a long-only option with a

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.