简体   繁体   English

ASP.NET default.aspx不会使用CSS呈现,但是网站的其余部分会显示

[英]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. 我对ASP等非常陌生,所以我有点迷路。 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. 问题是,default.aspx页面没有使用CSS呈现,但是其余的网页却是CSS。 The site is on a development IIS 7 server. 该站点位于开发IIS 7服务器上。 When I type the address in ie MyDomain.com/MySite, the default page loads, but without any CSS. 当我在MyDomain.com/MySite中键入地址时,将加载默认页面,但没有任何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. 如果单击菜单上的某个项目,则该项目与所有CSS等都可以完美显示。如果单击返回首页,则没有CSS。

As I said, I'm new to ASP and can't quite seem to find where the CSS is even defined at. 正如我所说,我是ASP的新手,似乎无法找到CSS的定义位置。 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. 默认页面的顶部没有定义CSS文件,但是如果我对另一个页面进行同样的操作,则它们位于顶部。 All pages used the same site.master. 所有页面使用相同的site.master。 All the CSS files are in an App_Theme folder in the project area. 所有CSS文件都位于项目区域的App_Theme文件夹中。

I would strongly encourage the standard use of CSS, rather than using Themes as an abstraction. 我强烈鼓励CSS的标准使用,而不是将Themes作为抽象。 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. 应该在首页的首页上引用CSS。 If your other pages have style attached this will override the css page however. 如果您的其他页面附加了样式,则它将覆盖CSS页面。 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. 当处理CSS时,查看源代码不是最佳选择,请为firefox安装firebug或使用Google chrome并选择F12,因为这将使您看到CSS并更改即席显示以查看有效的方法以及对页面元素有影响的内容。 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) 我怀疑默认值没有引用相同的母版页,因此可能是在Web表单顶部添加它的情况(我假设它不是MVC)

I got it fixed. 我把它修好了。 I found out about the <%Page Themes tag, and added that to the default.aspx page, and it works. 我发现了有关<%Page Themes标记的信息,并将其添加到default.aspx页面,并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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