App_theme not adding styles to web page - asp.net

I have a web site project that uses an App_theme folder for styles. When I run the site the styles are not applied to the site. What is going on?
It works on other developers computers, but they are using a local IIS 7 server whereas I am using the built in Visual Studio IIS. Note - the site is setup using a web site project (not application).

Maybe the problem is in incorrect folder name - ~/App_Themes instead of yours App_theme?
Right click on your website -> Add ASP.NET Folder -> App_Themes; this will add theme folder automatically, and then you will be able to add themes there.

To apply a theme to a WebSite, it is necessary to set the element to the name of the theme, either a global theme or a page theme, as shown in the following example:
<configuration>
<system.web>
<pages theme="ThemeName" />
</system.web>
</configuration>
How to: Apply ASP.NET Themes

make sure the top of the page includes the "theme" attribute, here's an example of the default page
<%# Page Language="C#" ClientIDMode="Static" Title="Reset Sessions" MasterPageFile="~/site.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WorkbenchWeb.resetsession" Theme="Theme" StyleSheetTheme="Theme" %>

Theme is there, i check Init event and theme is in web.config for all pages, however for some reason css under App_Themes are not added to one of the pages. However, for other pages it's ok - added automatically.

Related

asp.net detect master file location change

I moved the ASP.NET master files to a different directory using the Solution Explorer.
Is there a way to propagate this change to the .aspx pages so that the MasterPageFile references get updated automatically?
(This leads me to another question - if I change the namespace or name of a class is there a way to automatically update this change in all files that use this class?)
Thanks.
To avoid renaming file path, you can just set maser page in web.configs.
<pages theme="Default" masterPageFile="~/Defaut.master">
...
</pages>
Creating Master Page (MasterPage in Web.config)

Add a WebPart to an Application page

I have a "Data view web part" created from SharePoint Designer. I added the web part to my visual studio project as a "Web Part" . I want to know how to add the web part to an application page.
Hi i know its kind of late but, today i had to do the same thing, so i followed a great answer on sharepoint.stackexchange.com. But basically is like adding any other asp.net control on an APS.NET page.
First you need to define the prefix for that assembly
<%# Register tagprefix="prefix" namespace="NameSpaceOfTheWebPart" assembly="FullAssemblyName" %>
ex:
<%# Register tagprefix="csm" namespace="MySolution.VisualWebPart" assembly="MySolution Version=1.0.0.0, Culture=neutral, PublicKeyToken=335eef5f6f60e56b" %>
and then add the web part to the page (on the main place holder) using the required attributes by asp.net (ID and runat).
<prefix:WebPartClassName ID="ID" runat="server" />
The only thing is that you won't be able to edit the page and modify the Web Part through the browser, if you need to modify any other property of the Web Part you will have to do it from the html or code behind.
here is the url of the link i followed:
https://sharepoint.stackexchange.com/questions/26508/is-it-possible-to-add-web-parts-to-an-application-page
i hope it helps.

What is the purpose of precompiledApp.config?

If you precompile a web site and keep it updatable, the ASP.NET parser can see from the Page directive that there is no codefile or codebehind and where to find the base class (inherits attribute).
<%# page language="C#" autoeventwireup="true" inherits="_Default, Precompiled"
theme="Default" validaterequest="false" %>
If the site is precompiled and not updatable, the .compiled files in the bin folder should give the ASP.NET runtime all the necesary information on how to instantiate the page classes.
So why is the precompiledApp.config needed?
Thanks!
It's used to indicate whether or not the ASPX/ASCX pages in your site are updateable or not. You can precompile and have the code behind compiled, but leave these pages updateable so you can make minor GUI-related tweaks should you wish.

How can I specify that ASP.NET themes should not be applied to a specific folder?

I happen to have an ASP.NET 2.0 project that I want to apply a site-wide theme to. As such, I've specified the theme in the web.config file by setting the "theme" attibute of the system.web.pages element.
Now, I've added a new folder containing third-party code that I do not wish to apply the theme to (in fact, I can't, because many of the third party pages do not have the head runat="server" tag as required by the ASP.NET theming system). Is there a way to specify a folder that should be excluded from the theme from within the web.config file, without having to alter any of the third-party pages?
You can override this with a page directive theming =false
alternatively, place a web config file in the folder, this will apply for that folder only.
This should demonstrate for you
http://www.aspdotnetfaq.com/Faq/how-to-apply-different-configuration-settings-in-web-config-to-specific-pages-and-folders-in-asp-net-website.aspx
Just an idea (that I have never tried):
maybe it's possible by using a location element in web.config, e.g:
<system.web>
<pages theme="MyTheme">
..
</system.web>
<location path="~/3rdPartyPages">
<system.web>
<pages theme=""></pages>
</system.web>
</location>

In Visual Studio, my Design view doesn't load the master page controls. Why?

It's just so much HRESULT E_FAIL, if you know what I'm talking about.
And if you use Visual Studio, you know what I'm talking about.
Similar thread, but not a duplicate: Is the design view for aspx pages in Visual Studio useful?
Any insight, including input from Microsoft MVPs (oh, I know you're out there) would be super cool.
There could be some possible reasons.
1st is if you have created a web form (aspx) page Nested it with Master Page;
and on the child page you registered a control where you have develop your page.
in short I want to say that.
You nested your child page in the Master page but on that child page you only registered some controls and nothing else.
So you can view the master page only on that child page.
You can't see the master page on the controller pages.
Because Controller pages are just partial pages so they don't load the master page.
Master Page <- Child Page <- Registered a control on child page
<%# Register Src="Ctrl_AdminReports.ascx" TagName="Ctrl_AdminReports" TagPrefix="uc1" %>
you can only access the master page controls on its direct child.
Try this:
Put your MasterPages in a seperate folder (if they aren't already. Call it masterpages. Then add this to your web.config:
<location path="MasterPage">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
This will allow anonymous access to that folder and allow access to the masterpage. Also, are these nested masterpages?

Resources