Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the theme from one ASP.NET page in a project

We have a page that creates a printable version of the customer's bill. We are using themes via <pages styleSheetTheme="CityDesign">. This page is not using the Master page nor has any style sheet associated with it. I have added <%@ Page Language="C#" EnableTheming="false" Theme="" %> to the page and protected void Page_PreInit(object sender, EventArgs e) { Page.Theme = String.Empty;} to the code behind. The page still has the theme applied. What am I doing wrong?

like image 252
Mike Wills Avatar asked Sep 20 '10 21:09

Mike Wills


People also ask

How do you exclude an ASP.NET page from using themes?

Answer: To remove themes from your page, use the EnableTheming attribute of the Page directive.

What is theme apply theme in ASP.NET with example?

ASP.NET themes are a collection of properties that define the appearance of pages and controls in your Web site. A theme can include skin files, which define property settings for ASP.NET Web server controls, and can also include cascading style sheet files (. css files) and graphics.


2 Answers

I figured it out I needed StylesheetTheme="" not Theme=""

like image 169
Mike Wills Avatar answered Nov 15 '22 07:11

Mike Wills


The accepted answer didn't work for me. I couldn't get anything to work in the markup, but this solution does work in the code-behind file (aspx.cs for example).

Just add this method to your code-behind file:

protected void Page_PreInit(object sender, EventArgs e)
{
    Page.Theme = "";
}
like image 44
musefan Avatar answered Nov 15 '22 06:11

musefan