in

SDT Community Server

SDT Forums, Blogs, Photos server.

Floating Heart

No description is bad.

February 2008 - Posts

  • ASP.NET 2.0页面框架的几点新功能

    http://www.cnblogs.com/guow3c/articles/287291.html

    1. 新增的页面事件
      在ASP.NET 2.0中,一个ASP.NET页面的生命周期主要为(红色字体表示ASP.NET 2.0新增加的阶段页面事件):客户端请求页面—》预初始化(OnPreInit)—》初始化(OnInit)—》完成初始化(OnInitComplete)—》载入ViewState(LoadViewState)—》处理回送数据(IPostBackDataHandler)—》Page_OnPreLoad—》Page_OnLoad—》回发更改通知(RaisePostDataChangedEvent)—》处理回发事件(RaisePostBackEvent)—》Page_OnLoadComplete—》预呈现(OnPreRender)—》完成预呈现(OnPreRenderComplete)—》保存ControlState(SaveControlState)—》保存ViewState(SaveViewState)—》呈现(Render)—》Page_UnLoad。
    2. OnPreInit:在初始化页面OnInit事件前触发。在这个阶段里,可以进行定义站点主题(Theme)或加载站点个性化所需要的数据信息等操作。
    • OnInitComplete:完成初始化页面OnInit事件后触发。
    • OnPreLoad:在加载页面OnLoad事件前触发。
    • OnLoadComplete:完成页面加载OnLoad事件后触发。
    • OnPreRenderComplete:在完成预呈现OnPreRender事件后触发。这是完成页面呈现的最后一道关卡,在此之后,页面将无法再进行任何呈现上的改动。
    • SaveControlState:保存控件状态ControlState。ControlState是ASP.NET2.0控件新增的一个属性,类似ViewState作用,但它们区别在于ControlState用于保存更加重要的控件状态信息,以保证在禁用ViewState的情况下还可以对控件状态进行读写操作。
    1. 增加对页面Header的控制:
      System.Web.UI.Page类新增加了Header属性,用于对HTML页面头区域里数据的操作。通过对Header属性的跟踪,可以发现,Header属性保存着一个实现IPageHeader接口的对象(该对象有LinkedStyleSheets、Metadata、StyleSheet和Title四个属性),实际上正是通过这个对象实现对HTML页面头区域里数据的操作的。例如:
      <script runat="server">
      void Page_Load(object sender, System.EventArgs e)
      {
         
      this.Header.Metadata.Add("author", "brooks");
      }
      </script>

      其运行结果为:
      <html>
      <head> <title>Untitled Page</title>
         
      <meta name="author" content="brooks" />
      </head>
    2. 定义表单中的默认按钮:
      在ASP.NET1.0中,我就为了设置表单中的默认按钮而一筹莫展。幸好ASP.NET2.0把这个功能补上了,现在可以非常方便的设置表单中的默认按钮了。
      <%@ page language="C#" %>
      <script runat="server">
      void Button1_Click(object sender, System.EventArgs e)
      {
         
      this.LB_Message.Text = "You clicked button1";
      }
      </script>
      <html>
      <head runat="server">
         
      <title>Untitled Page</title>
      </head>
      <body>
         
      <form runat="server" defaultbutton="Button1">
             
      <asp:textbox id="Textbox1" runat="server"></asp:textbox>
             
      <asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" />
             
      <asp:label id="LB_Message" runat="server"></asp:label>
         
      </form>
      </body>
      </html>
    3. 设置焦点
      现在假设为TextBox1控件设置焦点,在ASP.NET 2.0中可以这样实现:
      this.Textbox1.Focus();  this.SetFocus(this.Textbox1); 即可为TextBox1控件设置焦点。
      如果打算也为表单设置个默认焦点控件,让光标默认停留在TextBox1上:
      <form runat="server" defaultfocus="TextBox1">
    4. 跨页面数据发送
      如果你需要多个页面发送数据到同一个表单程序进行处理,或者数据在多个页面之间传输处理的话,你就可以使用ASP.NET 2.0这个新特性。例如,我打算把Default.aspx页里TextBox1里的文本数据发送到Default2.aspx页面进行处理:
      Default.aspx页:
      <%@ Page Language="C#" %>
      <script runat="server">
         
      void Button2_Click(object sender, EventArgs e)
          {
              Label1.Text
      = "Hi," + TextBox1.Text + ". This is Default.aspx";
          }
      </script>

      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
         
      <title>Untitled Page</title>
      </head>
      <body>
         
      <form id="form1" runat="server">
             
      <asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
             
      <asp:Button ID="Button1" Runat="server" Text="PostToAnotherPage" PostBackUrl="~/Default2.aspx" />
             
      <asp:Button ID="Button2" Runat="server" Text="PostToSelf" OnClick="Button2_Click" />
             
      <br />
             
      <asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
         
      </form>
      </body>
      </html>
      Default2.aspx页:
      <%@ Page Language="C#" %>
      <script runat="server">
         
      void Page_Load(object sender, System.EventArgs e)
          {
              TextBox textBox1
      = (TextBox)PreviousPage.FindControl("TextBox1");
             
      this.Label1.Text = "Hi," + textBox1.Text + ". This is Default2.aspx!";
          }
      </script>
      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
         
      <title>Untitled Page</title>
      </head>
      <body>
         
      <form id="form1" runat="server">
         
      <asp:label id="Label1" runat="server"></asp:label>
         
      </form>
      </body>
      </html>
    5. asp.net 2.0中的defaultulr属性

      在asp.net 2.0中,在web.config文件中,新增加了defaulturl属性,这个可以在用户登陆后,转向指定的一个页面。当在.net 2.0中使用RedirectFromLoginPage() 方法时,将自动跳转到defaulturl指定的地址,下面是个例子
        
      <authentication mode="Forms">
        <forms loginUrl="member_login.aspx"
               defaultUrl="index.aspx" />
      </authentication>
    1. Constructor

    Always

    Construct

    Always

    TestDeviceFilter

    Always

    AddParsedSubObject

    Always

    DeterminePostBackMode

    Always

    OnPreInit

    Always

    LoadPersonalizationData

    Always

    InitializeThemes

    Always

    OnInit

    Always

    ApplyControlSkin

    Always

    ApplyPersonalization

    Always

    OnInitComplete

    Always

    LoadPageStateFromPersistenceMedium

    Always

    LoadControlState

    Always

    LoadViewState

    Always

    ProcessPostData1

    Always

    OnPreLoad

    Always

    OnLoad

    Always

    ProcessPostData2

    Always

    RaiseChangedEvents

    Always

    RaisePostBackEvent

    Always

    OnLoadComplete

    Always

    OnPreRender

    Always

    OnPreRenderComplete

    Always

    SavePersonalizationData

    Always

    SaveControlState

    Always

    SaveViewState

    Always

    SavePageStateToPersistenceMedium

    Always

    Render

    Always

    OnUnload

    Always

  • Posted Feb 29 2008, 03:31 PM by wicky with 1 comment(s)
    Filed under:
  • Enter Key in ASP.NET - Complete Research

    http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx

    One of the common requests in ASP.NET is to submit a form when visitor hit an Enter key. That could be a case if, for example you want to make Login Screen. It is expected that user just hit enter when he insert a password instead to of forcing him to use a mouse to click login button. If you want to make search function on your web site, it is frequently required to give a possiblity to hit enter after you insert a search terms instead of mouse click on a Search button.

    In classic HTML or ASP pages, it is not hard to submit forms using the enter key. Programmer use a <input type="submit"> to make a default button. If web site visitor click on that button or press enter key, the form will be submited.

    Off course, you can have a more than one form on your page and individual submit button for every form.

    You don't want to submit a form with Enter key?

    Rarely, you will need to disable an Enter key and avoid to submit form. If you want to prevent it completely, you need to use OnKeyDown handler on <body> tag of your page. The javascript code should be:

      if (window.event.keyCode == 13)
    {
        event.returnValue=false;
        event.cancel = true;
    }
     


    ASP.NET problems with Enter key

    If you try to use Enter key in ASP.NET, according to your browser's type, you can get really weird results. Try to place one ASP.NET textbox and a button to the web form. Write a code on a OnClick event of a button. That could be something simple, like:

      Response.Write("The button was clicked!");  

    Now start debuging and write something to textbox. If you press enter while focus is on textbox, form will submit, but your code for button's click event will not be executed.

    Stop the debuging and place one simple HTML textbox to the form. You will not write anything in this textbox, so you can make it invisible. Just place this HTML code somewhere inside of your form tag.

      <INPUT type="text" style="VISIBILITY: hidden;POSITION: absolute">  

    Start debuging again. You cannot see the second textbox, and everything looks like before. Try again to write something in visible textbox. If you press enter now, form will submit, and also your code for button's click event will be executed. This is extremelly different behavior, and you did nothing except you placed one inivisible HTML textbox on web form. :)

    Maybe it is not elegant, but placing invisible textbox could be simple solution for you if you have only one button on your web form. But, what if you have a different situation? What if you have a few buttons with only one textbox, more than one text box with only one button, or many text boxes and many buttons on form?

    Different browsers has a different behaviors in these cases. if you have more buttons, only first button will be "clicked" every time. So, we need some other approach to get an universal solution.


    How to make a default button in ASP.NET

    We need to specify exactly what button will be "cliked" when visitor press Enter key, according to what textbox currently has a focus. The solution could be to add onkeydown attribute to textbox control:

      TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");  

    This line of code will cause that button Button1 will be "clicked" when visitor press Enter key and cursor is placed in TextBox1 textbox. On this way you can "connect" as many text boxes and buttons as you want.

    Easy solution for default button

    There is a free component that allows you to assign a button to the "enter-pressed" client side event of input controls. If you type some text in textbox and press Enter, the form will postback, and the serverside click event of your button is fired.You don't need to write any code You only need to use control's "DefaultButton" property. It you are a beginner programmer this could be a life saver. More about MetaBuilders DefaultButtons Control you can find at http://www.metabuilders.com/Tools/DefaultButtons.aspx


    Default buttons in ASP.NET 2.0

    ASP.NET 2.0 makes this problems easier and introduce a concept of a "default button". New defaultbutton attribute can be used with <form> or <asp:panel> control. What button will be "clicked" depends of where acutally cursor is and what button is choosen as a default button for form or a panel.

    Here is sample HTML code that contains one form and one panel control:

      <form defaultbutton="button1" runat="server">
        <asp:textbox id="textbox1" runat="server"/>
        <asp:textbox id="textbox2" runat="server"/>
        <asp:button id="button1" text="Button1" runat="server"/>

        <asp:panel defaultbutton="button2" runat="server">
            <asp:textbox id="textbox3" runat="server"/>
            <asp:button id="button2" runat="server"/>
        </asp:panel>

    </form>

    Posted Feb 26 2008, 02:42 PM by wicky with 1 comment(s)
    Filed under:
  • IIS ASP.NET Tab Missing

    There are lots of case on internet.

    Solution 1 (work for me):

    1) Stop the IIS Admin service (and any services that depend on it)
    2) Open C:\WINDOWS\system32\inetsrv\MetaBase.xml in notepad or your favorite XML Editor. _DELETE_ the line that reads ‘Enable32BitAppOnWin64=”TRUE”’ 3) Start -> Run -> iisreset

    Solution 2:

    To fix, check the following 3 regkeys -
    HKEY_CLASSES_ROOT\CLSID\{7D23CCC6-A390-406E-AB67-2F8B7558F6F6}\InprocServer32
    HKEY_CLASSES_ROOT\CLSID\{FD5CD8B1-6FE0-44F3-BBFB-65E3655B096E} \InprocServer32
    HKEY_CLASSES_ROOT\CLSID\{FEDB2179-2335-48F0-AA28-5CDA35A2B36D}\InprocServer32

    Under (expand) InProcServer32, look for the presence of a non-2.0.0.0 (example 2.0.36.0) and remove it.
    It has a reference that causes this to break.
    If you do not have this MMC interface,  you can use aspnet_regiis.exe
    aspnet_regiis -s <path> where path equals the location in the metabase where you want the mappings to change.
    Note:  There is also a switch to do this non-recurvisely if you desire.

    Solution 3:

    uninstall and reinstall IIS
    unregister and re-register 1.1 and 2.0 with aspnet_regiis

     

    Posted Feb 21 2008, 10:42 AM by wicky with no comments
    Filed under:
  • Performance Comparison: XPO.NET and ADO.NET Data Access Techniques

    http://www.devexpress.com/Products/NET/Libraries/XPO/PerformanceComparisonXPOvsADO.xml

    Please read details by above link.

    Conclusion

    As these tests demonstrate, the number of records to be created does not impact data creation overhead introduced by XPO.NET classes. Note that database storage type is an important factor in this.

    The data reading overhead of XPCollection class varies from 30% to 70% and depends upon the amount of data to be read and the database storage type. To read and process large amounts of data you can use XPCursor and XPPageSelector classes that are specifically designed for these purposes.

  • VS 2008 Web Development Hot-Fix Roll-Up Available

    http://weblogs.asp.net/scottgu/archive/2008/02/08/vs-2008-web-development-hot-fix-roll-up-available.aspx

    One of the things we are trying to do with VS 2008 is to more frequently release public patches that roll-up bug-fixes of commonly reported problems.  Today we are shipping a hot-fix roll-up that addresses several issues that we've seen reported with VS 2008 and Visual Web Developer Express 2008 web scenarios.

    Hot Fix Details

    You can download this hot-fix roll-up for free here (it is a 2.6MB download).  Below is a list of the issues it fixes:

    HTML Source view performance

    • Source editor freezes for a few seconds when typing in a page with a custom control that has more than two levels of sub-properties.
    • “View Code” right-click context menu command takes a long time to appear with web application projects.
    • Visual Studio has very slow behavior when opening large HTML documents.
    • Visual Studio has responsiveness issues when working with big HTML files with certain markup.
    • The Tab/Shift-Tab (Indent/Un-indent) operation is slow with large HTML selections.

    Design view performance

    • Slow typing in design view with certain page markup configurations.

    HTML editing

    • Quotes are not inserted after Class or CssClass attribute even when the option is enabled.
    • Visual Studio crashes when ServiceReference element points back to the current web page.

    JavaScript editing

    • When opening a JavaScript file, colorization of the client script is sometimes delayed several seconds.
    • JavaScript IntelliSense does not work if an empty string property is encountered before the current line of editing.
    • JavaScript IntelliSense does not work when jQuery is used.

    Web Site build performance

    • Build is very slow when Bin folder contains large number of assemblies and .refresh files with web-site projects.

    Installation Notes

    For more information on how to download and install the above patch, please read this blog post here.  In particular, if you are using Windows Vista with UAC enabled, make sure to extract the patch to a directory other than "c:\" (otherwise you'll see an access denied error).

    To verify that this hot-fix patch successfully installed, launch VS 2008 and select the Help->About menu item.  Make sure that there is an entry that says ‘Hotfix for Microsoft Visual Studio Team System 2008 Team Suite – ENU (KB946581)’. 

    If you ever want to remove the patch, go to Control Panel -> Add/Remove Programs and select “Hotfix for Microsoft Visual Studio 2008 – KB946581” under Microsoft Visual Studio 2008 (or Visual Web Developer Express 2008) and click “Remove".

    Summary

    Obviously it goes without saying that we would have liked to have shipped without any bugs.  Hopefully this hot-fix enables you to quickly solve them if you are encountering them.  Thank you to those who helped us identify the causes of these issues, as well as to the group of customers who have helped us verify the above fixes the last few weeks.

    Note: If you do encounter issues with VS 2008 features for web development in the future, I recommend always asking for help in the VS 2008 Forum on www.asp.net.  The VS Web Tools team actively monitors this forum and can provide help.

    Hope this helps,
    Scott

    Posted Feb 14 2008, 02:13 PM by wicky with 1 comment(s)
    Filed under:
  • How to extend the Windows Server 2008 evaluation period

    http://support.microsoft.com/kb/948472/en-us

    INTRODUCTION

    loadTOCNode(1, 'summary');
    Evaluating Windows Server 2008 software does not require product activation. Any edition of Windows Server 2008 may be installed without activation, and it may be evaluated for 60 days. Additionally, the 60-day evaluation period may be reset (re-armed) three times. This action extends the original 60-day evaluation period by up to 180 days for a total possible evaluation time of 240 days.

    Note Although you can reset the 60-day evaluation period, you cannot extend it beyond 60 days at any time. When you reset the current 60-day evaluation period, you lose whatever time is left on the previous 60-day evaluation period. Therefore, to maximize the total evaluation time, wait until close to the end of the current 60-day evaluation period before you reset the evaluation period.

    Back to the top

    MORE INFORMATION

    loadTOCNode(1, 'moreinformation');

    How to install Windows Server 2008 without activating it

    loadTOCNode(2, 'moreinformation');
    1. Run the Windows Server 2008 Setup program.
    2. When you are prompted to enter a product key for activation, do not enter a key. Click No when Setup asks you to confirm your selection.
    3. You may be prompted to select the edition of Windows Server 2008 that you want to evaluate. Select the edition that you want to install.

    Note After Windows Server 2008 is installed, the edition cannot be changed without reinstalling it.
    4. When you are prompted, read the evaluation terms in the Microsoft Software License Terms, and then accept the terms.
    5. When the Windows Server 2008 Setup program is finished, your initial 60-day evaluation period starts. To check the time that is left on your current evaluation period, run the Slmgr.vbs script that is in the System32 folder. Use the -dli switch to run this script. The slmgr.vbs -dli command displays the number of days that are left in the current 60-day evaluation period.

    Back to the top

    How to manually extend the evaluation period

    loadTOCNode(2, 'moreinformation'); When the initial 60-day evaluation period nears its end, you can run the Slmgr.vbs script to reset the evaluation period. To do this, follow these steps:
    1. Click Start, and then click Command Prompt.
    2. Type slmgr.vbs -dli, and then press ENTER to check the current status of your evaluation period.
    3. To reset the evaluation period, type slmgr.vbs –rearm, and then press ENTER.
    4. Restart the computer.
    This resets the evaluation period to 60 days.

    Back to the top

    How to automate the extension of the evaluation period

    loadTOCNode(2, 'moreinformation'); You may want to set up a process that automatically resets the evaluation period every 60 days. One way to automate this process is by using the Task Scheduler. You can configure the Task Scheduler to run the Slmgr.vbs script and to restart the server at a particular time. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Task Scheduler.
    2. Copy the following sample task to the server, and then save it as an .xml file. For example, you can save the file as Extend.xml.
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2007-09-17T14:26:04.433</Date>
        <Author>Microsoft Corporation</Author>
      </RegistrationInfo>
      <Triggers>
        <TimeTrigger id="18c4a453-d7aa-4647-916b-af0c3ea16a6b">
          <Repetition>
            <Interval>P59D</Interval>
            <StopAtDurationEnd>false</StopAtDurationEnd>
          </Repetition>
          <StartBoundary>2007-10-05T02:23:24</StartBoundary>
          <EndBoundary>2008-09-17T14:23:24.777</EndBoundary>
          <Enabled>true</Enabled>
        </TimeTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>domain\alias</UserId>
          <LogonType>Password</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <IdleSettings>
          <Duration>PT10M</Duration>
          <WaitTimeout>PT1H</WaitTimeout>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>true</WakeToRun>
        <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
        <DeleteExpiredTaskAfter>PT0S</DeleteExpiredTaskAfter>
        <Priority>7</Priority>
        <RestartOnFailure>
          <Interval>PT1M</Interval>
          <Count>3</Count>
        </RestartOnFailure>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>C:\Windows\System32\slmgr.vbs</Command>
          <Arguments>-rearm</Arguments>
        </Exec>
        <Exec>
          <Command>C:\Windows\System32\shutdown.exe</Command>
          <Arguments>/r</Arguments>
        </Exec>
      </Actions>
    </Task>
    
    
    3. In the sample task, change the value of the following “UserID” tag to contain your domain and your alias:
    <UserId>domain\alias</UserId>
    4. In the Task Scheduler, click Import Task on the Action menu.
    5. Click the sample task .xml file. For example, click Extend.xml.
    6. Click Import.
    7. Click the Triggers tab.
    8. Click the One Time trigger, and then click Edit.
    9. Change the start date of the task to a date just before the end of your current evaluation period.
    10. Click OK, and then exit the Task Scheduler.
    The Task Scheduler will now run the evaluation reset operation on the date that you specified.

    Back to the top


    APPLIES TO
    Windows Server 2008 Enterprise
    Windows Server 2008 Standard
    Windows Web Server 2008
    Windows Server 2008 Datacenter
    Windows Server 2008 Datacenter without Hyper-V
    Windows Server 2008 Enterprise without Hyper-V
    Windows Server 2008 for Itanium-Based Systems
    Windows Server 2008 Standard without Hyper-V
    Posted Feb 14 2008, 08:23 AM by wicky with no comments
    Filed under:
  • What is Theme?


    http://weblogs.asp.net/vimodi/articles/ThemesFaqs.aspx

    What is Theme?

    Theme is a collection of control styles applied to webcontrols on website. It gives the common looks and feel to all webcontols in a simple way. Its allows to abstract the styles so that it can be reused. So from the software engg point of it satisfy the reusability and easy maintainance quality.

    • Theme only works for WebControls
    • MasterPage can not define Theme but Theme can be set in the content pages.
    • Control style defined in Theme will override the control style define in a page.
    • Doesnt work at Design Time but StyleSheetTheme works
    • Its collection of .skin and .css files
    • Themes doesnt apply to page or control if EnableTheming="false"  declare on it.
    • If themes applied dynamically (runtime) then it should be set in before Page_Preinit.

    How do i apply Theme to my site?

    To apply a Theme to app user need to create a folder with name App_Themes under application root directory and then create a folder with the name of Theme within App_Themes folder.
    For example if I want to create a Blue theme for my WebSite then folder structure will look like as shown in image.

    To Set Theme for the entire site define a theme in web.config file like

    <system.web>
          <pages theme="Blue" />
    </system.web>

    To apply Theme to a page define a theme in a page directive like

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

    To apply Theme dynamically (at runtime)

    protected void Page_PreInit(object sender, EventArgs e)
    {
    Page
    .Theme = "Blue";
    }

    What is a .skin file?

    Thats the file which will contain the styles applied to webcontrols.
    eg. <asp:Label runat=server Text="ThemedLabel" BackColor="Red" /> (This is called default skin for label)
    If the Theme containing above skin file is applied to a page then all the labels on a page will be shown with Text="ThemedLabel" BackColor="Red"

    If there is no skinid defined in the control defination then that its consider as a default skin for that control.

    • Controls defined in the .skin file should NOT contain ID.
    • Error will be thrown if two default control skin is declared for the same type of control in .skin file.
    • Any kind of code or expressions are not allowed in skin file.

    How to defind different Style(skin) for the same control?

    Using SkinID different skin for a control is defined.

    eg. <asp:Label runat=server Text="ThemedLabel" BackColor="Red" /> - Default skin for Label

    <asp:Label runat=server SkinId="BoldLabel" Text="ThemedLabel_WithSkinId" BackColor="Blue" Font-Bold="true" /> - BoldLabel skin for Label

    So if Themed page contain a label without any SkinID then default skin will be applied to that label and if there is any Label exists with SkinID="BoldLabel" then Label will be shown with Text="ThemedLabel_WithSkinId" BackColor="Blue" Font-Bold="true" 

    Different ways to organize the theme folder contents.

    Since theme folder can contain many .skin files. so you can organise your theme folder in different ways. All the skin files get merged before theme is applied to page.

    • Just one .skin file that contain all control skin definations.
    • Create one .skin file for each control.
    • Group same the SkinIDs in one .skin file

    Is there a way to share Theme between different Apps?

    Using Global Theme is way to share Theme between different Apps.eg if you want to create a Global Theme called theme1

    • For Cassini server create a Theme1 folder inside framework folder like \WINDOWS\Microsoft.NET\Framework\v2.0.xxxxx\ASP.NETClientFiles\Themes\Theme1
    • For IIS server create a Theme1 folder inside like  \Inetpub\wwwroot\aspnet_client\system_web\v2.0.xxxxx\Themes\Theme1

    Application level Theme will override the Global theme. ie if Theme named Blue is defined at Global and Application level then application level Blue theme will be applied to the site

     

    Posted Feb 03 2008, 10:37 AM by wicky with 1 comment(s)
    Filed under:
  • What is a StyleSheetTheme?

    http://weblogs.asp.net/vimodi/articles/WhatIs_StyleSheetTheme.aspx

    What is a StyleSheetTheme?

    Basically StyleSheetTheme is a Theme which gets applied in very early page cycle before the page control properties applied.

    So order is like
        StyleSheetTheme -> Page -> Theme

    That means control property set in StyleSheetTheme can be overridden by the control property in Page and control property set in Page can be overridden by the control property in Theme.

    For example if StyleSheetTheme contain following default Label skin.
    <asp:Label runat="server" Text="StyleSheetLabel" Font-Size="Small" BackColor="Red" ></asp:Label>

    and Page Which has StyleSheetTheme and Theme defiened contain a Label contol as
    <asp:Label runat="server" Text="PageLabel" Font-Size="X-Large" ></asp:Label>

    and Theme contain following default label skin.
    <asp:Label runat="server" Text="ThemedLabel" ></asp:Label>

    Then the resultant Label shown will look like.
    <asp:Label runat="server" Text="ThemedLabel" Font-Size="X-Large" BackColor="Red" ></asp:Label>

    Above example is just to show the precedence heirarchy but generally either StyleSheetTheme or Theme will be applied to the page and not both.
    StyleSheetTheme has same characteristics Theme except few differences.

    • StyleSheetTheme works in Designer
    • To apply StyleSheetTheme at Site Level define following in web.config

      <system.web>
            <pages styleSheetTheme="Theme1" />
      <system.web>

    • To apply StyleSheetTheme at Page Level

      <%@ Page Language="C#" StylesheetTheme="Theme1"%>

    • To apply StyleSheetTheme dynamically user need to override the StyleSheetTheme property.

      public override string StyleSheetTheme
      {
         get{ retrun "MyStyleSheetTheme"; }
      }

    • To apply a StyleSheetTheme to a control added dynemically user need to call ApplyStyleSheetTheme(Page) method on the control.

      Label lab1 = new Label();
      lab1.ApplyStyleSheetSkin(
      this);

    • EnableThemeing doesnt work with StyleSheetTheme. Setting EnableTheming="false" doesnt stop applying StyelSheetTheme to the page or control.
    • Can not apply SkinId dynemically.

    Posted Feb 03 2008, 10:36 AM by wicky with 1 comment(s)
    Filed under:
Copyright SDT, 2006-2009. All rights reserved.