Peeling new for .Net 2.0

.Net 2.0 Skins

    Baked .Net 2.0 is undoubtedly another gospel of our developers. New features in .Net 2.0 has attracted attention of many people. .Net 2.0 of skins which is making us greatly shorten the development cycle of a number of Web applications, today, we have to learn and explore under .Net 2.0 of skins together.
    First, we create a new Web project, add a right-Skin file (we named Default), the Skin file, we can customize our need to control the style. We can note, the new Skin files are located App_Themes file in the root directory folder.
    Such as: our custom styles for the Label control: font color to red

                < asp:Label ForeColor = " Red "  runat = " server "   />
    So how do we use good custom Skin file it? There are two ways:

    First: Add Theme in the header file in Html code for that page = "*** (Skin filename)"      

                        <% @ Page Language = " C# "  Theme = " Default "   %>

    Second: the code of the page is added the Page_PreInit () method as follows:

 

        protected   void  Page_PreInit( object  sender, EventArgs e)
        {
              
this .Theme  =  “Default”;      // Default为Skin文件名
        }

    Third: In Web.Config configuration ( Note: Once you have set all the way back to the pages of the Web application will use the Skin

         Followed by a period <pages theme = "Default" /> at the web.config <system.web> node

    In this way, we can put a file named Default Skin skin set the style applied to the page. I write to you, and my heart there must be such a question: Can I set more to the style of a control in the Skin skin file it? The answer is yes, we just add SkinID file attributes Skin identified. If you do not specify the default SkinID. (Such as the above font to green)

            < asp:Label SkinID = " LabelStyle1 "  ForeColor = " Green "  runat = " server "   />

    In the pages of our introduction Default Skin file, if we want to use the Label control green font, then we just need to add a Label control SkinID = "LabelStyle1" can, otherwise it defaults to red.

    Now, we return to the question "how to achieve Web application skinning" up. Through the above description we should feel resurfacing is not difficult to achieve, we do a good job after several sets of skin styles, we write a page base class, the base class we read into the skin styles Page_PreInit () event, if not then call the default skin style. We store style skin There are many methods: databases, files, configuration files, Cookie, Session and so on. I believe you already know how to skinning it.

    In addition, I would explain how to disable some style Skin file that we set up in the page. We only need to control EnableTheming property is set to false

    when we refer to the Skin file, in accordance with the style I wanted a control is now set in the page display, we can also be replaced by StylesheetTheme = "Default" when referring Skin file Theme = "Default". Below we explain the difference between the two

    Theme: Gets or sets the name column of the page. (Note: the user uses when referring to the way skin files, we included in the property of a control on the page to make changes again, the page does not change, it will apply the skin in the style file)

    StylesheetTheme: Gets or sets the name of the style sheet applied to this page of. (Note: the user uses when referring to the way skin files, we included in the property of a control on the page to make changes again, the page will be displayed with priority in accordance with the pattern set in the page)
 

Reproduced in: https: //www.cnblogs.com/shimeng3344518/archive/2007/04/15/714187.html

Guess you like

Origin blog.csdn.net/weixin_34043301/article/details/94682758