Thursday, June 13, 2013

Asp.Net Theme Example


  Apply theme is a beautiful concept in Asp.Net. We can set properties of a specific control and save it in skin file. Then all control of that type the properties fixed means if we set properties for a Gridview in skin file then all Gridview control all over the project will be same properties and same look.

 Steps-1 :-

   Right Click on website -> Add New Item -> SkinFile.skin

  Add the GridView properties there

  
<asp:GridView runat="server"   HeaderStyle-BackColor="#5D7B9D"
    HeaderStyle-ForeColor="White" AllowPaging="True" Font-Size="11px" HeaderStyle-Font-Size="11px"
    AllowSorting="True" CellPadding="4" ForeColor="#333333"
     GridLines="None" EmptyDataText="No record found." ShowFooter="True" >
    <AlternatingRowStyle BackColor="White" />
    <EmptyDataRowStyle  Font-Bold="true" Width="100%" HorizontalAlign="Center"/>
    <EditRowStyle BackColor="#2461BF" />
    <HeaderStyle Height="22px" BackColor="#18677C" ForeColor="White" Font-Bold="True" />
    <PagerStyle ForeColor="Gray" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F5F7FB" />
    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
    <SortedDescendingCellStyle BackColor="#E9EBEF" />
    <SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>

 Steps-2 :-

  Open Web.Config file and set this code for Page tag within <System.Web>

 

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

  
Then every GridView across project will be same.










 

No comments:

Post a Comment