Working with Themes in ASP.NET 2.0
page 3 of 10
by SANJIT SIL
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 42987/ 80

Removing Themes

Removing Theme from Server Control

Whether themes are set at application level or page level, we can set a control’s own style on it.

Listing 4

<asp:Textbox ID=”txtTest” Runat=”server”
BackColor=”White” ForeColor=”Black” EnableTheming=”false” />

If we apply myTheme at application or page level, the same theme will be applied in all controls except the "txtTest" textbox control as mentioned above. Instead, the backcolor and forecolor, as mentioned in the code snippet, will be applied.

Removing Theme from Web Pages

If we set the Theme for an entire application in the web.config file and then want to exclude a single ASP.NET page, we can do the same by removing Theme setting at the page level, just like server control. This is illustrated in Listing 5.

Listing 5

<% Page Language=“C#” EnableTheming=”false” %>

If we make EnableTheming attribute false in the page directive, the Theme defined in web.config file will not be applied in the page. But we can still provide Theme in respect of a specific server control in the same page. This is illustrated in Listing 6.

Listing 6

<asp:Textbox ID=”txtTest” Runat=”server” EnableTheming=”true” Theme=” myTheme”/>

Theme vs. StylesheetTheme

The Page directive also includes the attribute StylesheetTheme that we can use to apply themes to a page. So, the big question is: If we have a Theme attribute and a Stylesheet attribute for the page directive, what we should use?

Listing 7

<% Page Language=“C#” StylesheetTheme =”myTheme” %>

The StylesheetTheme attribute works the same as the Theme attribute to apply a Theme to a page. The difference is that, when attributes are set locally on the page within a particular server control, the attributes are overridden by the theme when we use the Theme attribute. But if we apply pages’s theme using the StylesheetTheme attribute, the locally set attributes of the server control will not be overridden.


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 3:19:29 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search