Using different themes for different customers
What is the best practice to apply different themes to different customers with asp.net.开发者_开发技巧
Use the built-in support for Themes and Skins.
What Justin said.
If what you're really asking is how to dynamically set the theme/skin on the request, then the answer would be to set the Theme property of the Page or MasterPage during PreInit.
In a nutshell, you can apply the Theme in page code-behind:
protected void Page_PreInit()
{
Page.Theme = "themeName";
}
To avoid having to type this for every page, you can put it in a base page that is inherited by each page you want to use the Theme.
Then, you just have to have a way to figure out from the user's information (probably stored in the database, retrieved on login, and carried around in a Session variable) which theme to use.
I save the preferred theme with the client's info in my DB and i have an HttpHandler that sets it.
精彩评论