Theme changing on the fly using ASP.Net 2.0
Posted on 8/18/2006 10:10:30 AM
in #ASP.NET 2.X
Hi/p> 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. /p>
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./p>
/o:p>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 /span>method
like this./o:p>/span> public override string StyleSheetTheme/o:p> /span>{/o:p> /span>get/o:p> /span>{ return HttpContext.Current.Profile["StylesheetTheme"].ToString();}/o:p> /span>set/o:p> /span>{ HttpContext.Current.Profile["StylesheetTheme"]
= value; }/o:p> /span>}/span>/p>
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./p>
/o:p>Profile.StylesheetTheme = "Ultra";/o:p> /span>Response.Redirect(Request.FilePath,
true);/o:p>/span>/p>
Also on the page load I am checking for the current theme and
making the correct Radio button checked. /p>
Also in the web.config file I added the following tag /span>/span><profile>/o:p> /span><properties>/o:p> /span><add name="StylesheetTheme"
defaultValue="Blue" /span>allowAnonymous="true" /span>//>/o:p> /span><//properties>/o:p> /span><//profile>/o:p>/span>/p>
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./o:p>/p>
/span>/span><anonymousIdentification
enabled="true" //>/o:p>/span>/p>
Hope this helps Thanks Vikram
|
Posted on 7/27/2007 12:00:20 PM
Sorry for saying this.
But this article is worthless, its first of all hard to figure out the "middle steps" the idea with the radio button is just not intelligent, a drop down list with many themes would be much more practical.
and at last it just dont work on the hole site.
/p>
|
Posted on 2/10/2008 8:37:41 AM
dear
where you written this class please provide me complete detail of code
/p>
public override string StyleSheetTheme
{
get
{ return HttpContext.Current.Profile["StylesheetTheme"].ToString();}
set
{ HttpContext.Current.Profile["StylesheetTheme"] = value; }
}
/p>
Thanks in advance.
/p>
|
Posted on 2/10/2008 8:54:46 AM
Hi shamshuddin,
/p>
The code is written in the BaseWebPage of all my classes.
/p>
Here is what the BaseWebPage class looks like
/p>
public class BaseWebPage:System.Web.UI.Page
{
public override string StyleSheetTheme
{
get
{
return HttpContext.Current.Profile["StylesheetTheme"].ToString();
}
set
{
HttpContext.Current.Profile["StylesheetTheme"] = value;
}
}
}
/p>
|
Posted on 3/16/2009 6:43:13 AM
Hai whilie running locally it is working fine, but while i am configure it in IIS it is giving the following error. Please help anybody regarding this.
/p>
"
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
"
/p>
and also the following error
/p>
Source Error:
/p>
Line 27: get
Line 28: {
Line 29: return HttpContext.Current.Profile["StylesheetTheme"].ToString();
Line 30: }
Line 31: set
/p>
|
Posted on 1/11/2011 5:45:25 PM
I am facing "Operation is Timed Out" SmtpException in the code for sending mail with more then one files. If you have solution then please inform me as soon as possible on my email id.
Thank You.
/p>
|