Themes e Skins

<< Click to Display Table of Contents >>

Navigation:  ASP.NET > Dicas avançadas >

Themes e Skins

Previous pageReturn to chapter overviewNext page

Muito simples. Não precisa nem de explicação

 

Solution

 

themesskin

 

Default.aspx

 

      <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

      <br />

      <asp:Button ID="Button1" runat="server" Text="Button" />

      <br />

      <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"

          Style="height: 22px">

          <asp:ListItem Selected="True">Gray</asp:ListItem>

          <asp:ListItem>Red</asp:ListItem>

      </asp:DropDownList>

 

 

Default.aspx.cs

 

using System;

using System.Web.UI;

 

public partial class _Default : System.Web.UI.Page

{

  protected void Page_Load(object sender, EventArgs e)

   {

 

   }

 

  protected void Page_PreInit(object sender, EventArgs e)

   {

      string thm;

       thm = (string)Session["themeSelected"];

      if (thm != null)

       {

           Page.Theme = thm;

           DropDownList1.Text = thm;

       }

      else

       {

           Session["themeSelected"] = DropDownList1.Text;

           Page.Theme = Session["themeSelected"].ToString();

       }

 

   }

 

  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

   {

       Session["themeSelected"] = DropDownList1.Text;

       Server.Transfer(Request.FilePath);   // eu mesmo!

   }

}

 

Red.skin

 

<asp:Label runat="server" Font-Names="Verdana" ForeColor="Red"/>

<asp:Button runat="server" Font-Bold="True" ForeColor="Brown"/>

<asp:RadioButtonList runat="server" Font-Bold="True" Font-Names="Verdana" ForeColor="Red"/>

 

Gray.skin

 

<asp:Label runat="server" Font-Names="Verdana" ForeColor="Gray"/>

<asp:Button runat="server" Font-Bold="True" ForeColor="DimGray"/>

<asp:RadioButtonList runat="server" Font-Bold="True" Font-Names="Verdana" ForeColor="Gray"/>