How to dynamically change themes at the website level

Source: Internet
Author: User

When creating a project, you are required to select your preferred topic. After a simple query of the information, the idea is basically as follows:
1. The database customer table has a field (temporarily named theme), which specifically records Customers' favorite topics.
2. After the customer logs on for the first time, the website displays the default theme mode, creates a session, queries the database, and assigns values to it (of course, the default value for the theme field of the new customer is default ). Based on the subject selected by the customer, you can save the subject to the database while changing the subject of the website. This topic is displayed after you log on again.

So the key point is how to dynamically change the subject of the entire website?

I use this solution:
1. Create a themepage class inherited from system. Web. UI. Page. This class overrides the onpreinit method:

1 protected overrides sub onpreinit () sub onpreinit (byval e as eventargs)
2 mybase. onpreinit (E)
3
4 if not SESSION ("theme") is nothing then
5 page. theme = SESSION ("theme ")
6 end if
7end sub
8
2. inherit all other pages from the themepage class, except for the logon page.

3. On the switch topic page, perform the following operations:

1if ddltheme. selectedindex = 0 then
2 SESSION ("theme") = "default" 'use the default theme
3 else
4 Session ("theme") = ddltheme. selectedvalue
5end if
6 updatetheme () 'store to database
Refresh the current page to display a new topic. You can do this:

Server. Transfer (request. filepath)

In this way, the dynamic global change of the topic can be realized. I hope to give you some reference. If there is a better method, please do not give me any further advice.

In addition, some technologies on ASP. NET topics are provided.Article:
Http://msdn2.microsoft.com/en-us/library/ms379601 (vs.80). aspx
Http://www.dedecms.com/web-art/Asp_Netjiaocheng/20060819/21832.html
Http://www.codeproject.com/useritems/dynamicThemes.asp
Http://www.codeproject.com/aspnet/ThemesAndSkins.asp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.