 |
|
 |
in asp.net 1.1?
thx
|
|
|
|
 |
|
 |
Nice article, my favorite kind: to the point, works and saves time.
One little tip that may or may not be dead obvious: If you have a reason to want to turn off the theming for testing, or because in our case the Telerik controls we use have a built in theme that is quite nice you just make an empty folder in your themes folder with a meaningful name like "NoTheme".
Cheers!
|
|
|
|
 |
|
 |
I spent some good hours trying to find out how smthng like this could be done. Thanks a lot, you look great btw. :->
sean
|
|
|
|
 |
|
 |
Hi there,
As an alternative you can load a theme from global.asax.cs, like so:
Override Init() and add the following code:
PreRequestHandlerExecute += delegate(object appsender, EventArgs appargs) {
Page page = HttpContext.Current.Handler as Page;
if (page != null)
page.PreInit += delegate(object pagesender, EventArgs pageargs) {
(pagesender as Page).Theme = HttpContext.Current.Request.QueryString["theme"];
};
};
This will work with masterpages.
I've kept the code compact, this is a silly example but it (hopefully) illustrates the point
Cheers,
Michel
|
|
|
|
 |
|
 |
Thank you for posting this information. I looked in several places, but none had this approach, which is what I was looking for. I do have one thing to add for anyone else who might want to change the StyleSheetTheme instead of just the Theme. In the Base.cs class I had to override the StyleSheetTheme property instead of the OnPreInit method. Like this: private string myTheme; public override string StyleSheetTheme { get { if (Session["MyTheme"] == null) { return "ThemeName"; } else { return (string)Session["MyTheme"]; } } set { myTheme = value; } } Hope that helps any future visitors!
|
|
|
|
 |
|
 |
Thanks gweeter, for the info on setting the StyleSheetTheme instead of Theme!
Googled for that for ages without any luck..
Also thanks to Sue for a great article!
|
|
|
|
 |
|
 |
Intread of this
public Theme(string name)
{
Name = name;
}
I'll use
public Theme(string name)
{
_name = name;
}
Sice you're calling the Name's Set intead of just updating the local (and private) variable.
I'm on a Fuzzy State: Between 0 an 1
|
|
|
|
 |
|
 |
Gonzalo Brusella wrote: I'm on a Fuzzy State: Between 0 an 1
Haaa haaa.... Holy Hell, thats a BIG bug mate ! Many people might call you crazy. But i know optimization during build/design has made more than 1000 times difference (usually O(log n)) in the past.
Abi ( Abishek Bellamkonda )
My Blog: http://abibaby.blogspot.com
=(:*
|
|
|
|
 |
|
 |
Sue, thanks for your article.
I suppose you could move the code from the BasePage to the MasterPage. This saves you from inheriting from BasePage in all your .aspx pages and makes the model even more easy.
|
|
|
|
 |
|
 |
DeKale wrote: I suppose you could move the code from the BasePage to the MasterPage.
Actually, you can't. The MasterPage class lacks a PreInit event. To programmatically assign a theme, you have to do it in either the page itself, in a base page (as Sue is showing), or with an HttpModule.
|
|
|
|
 |
|
 |
Yes, you're right about that. I'm sorry, wasn't paying attention.
|
|
|
|
 |
|
 |
First of all, tnx for this usefull piece of code.
I haven't test it yet on my website, but I can confirm you that there could be something wrong in the theme selector you implemented in your site.
When I clicked on the Red one the theme correctly switched, but now trying to select one of the other two doesn't affect anymore the appearance.
Maybe there are some conflicts/issues with cookies or sessions, cause waiting a couple of minutes the site allowed another theme change before blockin again.
Hope this helps
--
NinjaCross
www.ninjacross.com
|
|
|
|
 |
|
 |
You are correct, I set cache on some static pages such as "about me" & "favor quotes". I just updated it, should be working now.
Sue's edream
Fine craftmanship web development in ASP.NET 2.0
http://www.edream.org
|
|
|
|
 |
|
 |
Hi Sue,
It looks strange but visiting www.edream.com site I was able to change the theme only once (to red one). All my other attempts to make it green or yellow failed. Can you check?
ILog
|
|
|
|
 |
|
 |
Oops, sorry... This is only on resume page
ILog
|
|
|
|
 |
|
 |
I just updated it, should be working now. I set extra long cache on static pages, but for the shake for demo I just removed all the caches...
Sue's edream
Fine craftmanship web development in ASP.NET 2.0
http://www.edream.org
|
|
|
|
 |