Hi
Now the users can change the look and feel of the site as
per their choice in my site. You can change the radio button on the left and
accordingly the full theme (images, skin, and css) will change. This can be
done very easily in asp.net 2.0.
After my friend (Thanks to Farghana) created a new theme for
the site it required less than 10 line of code to change the theme on the fly.
Here
is how I did it. All my pages are inheriting from basewebpage which inherits from
System.Web.UI.Page. In basewebPage I overrode the StyleSheetTheme method
like this.
public override string StyleSheetTheme
{
get
{ return HttpContext.Current.Profile["StylesheetTheme"].ToString();}
set
{ HttpContext.Current.Profile["StylesheetTheme"]
= value; }
}
Here I am changing the stylesheet theme to use profiles StylesheetTheme.
Next I went to the master page and added 2 radio buttons. On the check changed
event of the radio button I set the profile to appropriate theme and redirected
the page to itself.
Profile.StylesheetTheme = "Ultra";
Response.Redirect(Request.FilePath,
true);
Also on the page load I am checking for the current theme and
making the correct Radio button checked.
Also in the web.config file I added the following tag
<profile>
<properties>
<add name="StylesheetTheme"
defaultValue="Blue" allowAnonymous="true" />
</properties>
</profile>
Here
I am adding a propert with name stylesheetTheme and giving the default tehme as
Blue. Also I want the Ananymous user to be able to switch from one theme to
another hence allowAnonymous="true". Also for this to work I have to
add the following tag to the config.
<anonymousIdentification
enabled="true" />
Hope this helps
Thanks
Vikram