简体   繁体   中英

ASP.NET default.aspx doesn't get rendered with CSS, but rest of the website does

I'm quite new to ASP etc, so I'm a bit lost. I've tried searching, but I can't seem to find my exact problem.

The code I've been working with is for a current website, and I've been trying to create a mobile variant with it.

The problem is, the default.aspx page isn't rendered with CSS, but the rest of the web pages are. The site is on a development IIS 7 server. When I type the address in ie MyDomain.com/MySite, the default page loads, but without any CSS. If I click an item on the menu, it displays perfectly with all the CSS etc. If I click back to the home page, no CSS.

As I said, I'm new to ASP and can't quite seem to find where the CSS is even defined at. If I load the pages, and right click and view source. The default page has no CSS files defined at the top, but if I do the same with another page, they're there at the top. All pages used the same site.master. All the CSS files are in an App_Theme folder in the project area.

I would strongly encourage the standard use of CSS, rather than using Themes as an abstraction. Themes can cause a number of problems for upgrading/adding/removing controls. They do not cascade well, either. Use the element in the of the master page.

CSS should be be referenced on the master page in the head section. If your other pages have style attached this will override the css page however. When dealing with CSS viewing the source is not the best option, either install firebug for firefox or use Google chrome and select F12 as this will let you see the css and alter adhoc to see what works and whats affecting elements of the page. I suspect the default is not referencing the same master page so it might be a case of adding that at the top of the web form (I'm assuming its not MVC)

I got it fixed. I found out about the <%Page Themes tag, and added that to the default.aspx page, and it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM