Themes are able to override the properties of Asp.Net controls i.e, if you assign the textbox property Backcolor as green then apply Simple theme, you observed that the textbox backcolor is in yellow only because we mention the backcolor as yellow in Theme.
If you don’t want to override the existing properties of Asp.Net controls, you can do with simple changes in your page.
Observe below code.
<%@ Page Language="VB" AutoEventWireup="false" StylesheetTheme="Simple" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txt1" BackColor="green" runat="Server" ></asp:TextBox> </div> </form> </body> </html>
In the above code we assign the theme name Simple to the StylesheetTheme attribute of Page directive. Then apply the Backcolor as green to the textbox and execute the page. You observe that textbox backcolor displayed as Green instead of Yellow(what we mentioned in Simple Theme).
Instead of applying the themes to each page you can mention it in web.config file for entire application.
<configuration> <system.web> <pages theme="Simple"> <namespaces> </namespaces> </pages> <system.web> <configuration>
In web.config file, for page tag you can set the theme value. You can observe above code, in that we assign the Simple theme to the theme attribute of pages tag.
In this way you can apply themes to particular page or for all pages in your application depending on your requirement.
<< Previous Download source code here
Subscribe
Filter by APML