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 8049955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:55:52+00:00 2026-06-05T06:55:52+00:00

I’ve been learning a bit of asp.net and I’ve been having issues with the

  • 0

I’ve been learning a bit of asp.net and I’ve been having issues with the whole dynamic theme change, I’ve been following a book that teaches how to do it via a drop down menu, but I wanted to challenge myself and do it with buttons.

My website has 2 themes and therefore, two buttons that represent each theme (orangefresh and greenfresh), this is my master page code behind:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class mpage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string selectedTheme = Page.Theme;
            HttpCookie webtheme = Request.Cookies.Get("webtheme");
            if (webtheme != null)
            {
                selectedTheme = webtheme.Value;
            }

        }
    }
    protected void orangefresh_Click(object sender, EventArgs e)
    {
        HttpCookie webtheme = new HttpCookie("webtheme");
        webtheme.Expires = DateTime.Now.AddMonths(3);
        webtheme.Value = "orangefresh";
        Response.Cookies.Add(webtheme);
        Response.Redirect(Request.Url.ToString());
    }

    protected void greenfresh_Click(object sender, EventArgs e)
    {
        HttpCookie webtheme = new HttpCookie("webtheme");
        webtheme.Expires = DateTime.Now.AddMonths(3);
        webtheme.Value = "greenfresh";
        Response.Cookies.Add(webtheme);
        Response.Redirect(Request.Url.ToString());
    }
}

And this is my Base Page:

using System;
using System.Web;
public class BasePage : System.Web.UI.Page
{
private void Page_PreInit(object sender, EventArgs e)
{
HttpCookie webtheme = Request.Cookies.Get("webtheme");
if (webtheme != null)
{
    Page.Theme = webtheme.Value;
}
}
public BasePage()
{
    this.PreInit += new EventHandler(Page_PreInit);
}
}

Seeing as I have no experience with cookies, I decided to look at the code from the beginning, I tested out if the Click event was storing a value on the cookie, I created a Label on the website and gave it’s .Text property the cookie’s .Value, nothing happened. So I started to remove code to see what was stopping the event, and I found that this line…

 Response.Redirect(Request.Url.ToString());

… was responsible for it. Just for the sake of it, I removed that one line and tested my website again, still, no changes in the theme.

Any help would be appreciated.

  • 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-06-05T06:55:53+00:00Added an answer on June 5, 2026 at 6:55 am

    Fixed. I forgot to make the change so that the page I was testing in inherited BasePage… it was inheriting the default page.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.