css样式在发布后不起作用
我有两个css类: 1.-highlightedsearchresult->在选中表格中的项目时高亮显示 2.-visitedsearchresult->标记已访问的项目 这两者都在my Site.css中定义:css样式在发布后不起作用,css,publish,Css,Publish,我有两个css类: 1.-highlightedsearchresult->在选中表格中的项目时高亮显示 2.-visitedsearchresult->标记已访问的项目 这两者都在my Site.css中定义: .highlightedsearchresult { border: medium solid #009999 !important; background-color: #FFCC66 !important; /* this should over
.highlightedsearchresult
{
border: medium solid #009999 !important;
background-color: #FFCC66 !important; /* this should overwrite the background color */
}
.visitedsearchresult
{
/* border: medium solid #FFFFFF !important;#6699CC #cc99cc #99CCFF*/
background-color: #cc99cc !important; /* this should overwrite the background color */
}
我的问题是,在本地或服务器上发布网站后,我的visitedsearchresult没有被应用highlightedsearchresult样式在published中应用正常,因此我知道它是对My site.css的一个不错的引用。当我在Visual Studio 2012下以调试模式运行网站时,两种css类样式都按预期应用
下面是适用于我的风格的代码:
$('.SearchResultsTable').on('click', 'tr', function () {
var index = this.rowIndex;
if (index == 0) {
return; //this is the header, do nothing
}
$(".highlightedsearchresult").each(function () {
$(this).addClass('visitedsearchresult'); //if item has the highlighted class, add the visited class before we removed the selected class
//alert("add visited class");
});
var state = $(this).hasClass('highlightedsearchresult');
if (!state) {
$(this).removeClass("visitedsearchresult"); //remove our visited class, thus the background is set as selected
$(this).addClass("highlightedsearchresult").siblings().removeClass("highlightedsearchresult");
}
else {
//alert("removing visited class");
$(this).removeClass("visitedsearchresult"); //remove our visited class, thus the background is set as selected
}
var storyUrl = '@Url.Action("StoryDisplay", "DisplayStory")';
var file = $(this).attr('SearchResultFilename'); //get filename from our custom attribute
storyUrl += "?filename=" + file;
$("#divdisplaystory").css("width", "74%");
$("#divsearchresults").css("width", "25%");
$("#divdisplaystory").show();
$('#divdisplaystory').loadWithoutCache(storyUrl);
});
如果有人知道为什么这种风格一经出版就行不通,我将不胜感激。任何帮助都将不胜感激
更新
我使用Fiddler Web Debugger查看了下面发生的事情,发现当访问发布网站时,我得到一个401:由于身份验证头无效,您无权查看此页面。我仍然可以使用这个网站,我所有的其他风格都被应用。此外,我正在屏幕上显示用户名@user.Identity.name,它显示的是正确的域\用户名。真奇怪。该站点已禁用匿名身份验证,并已启用Windows身份验证
非常感谢我不确定,但有时,当我想用java脚本选择一个id或类并在母版页中使用content palace holder时,标记的id或类在发布后会更改为ContentPlaceHolder\u myID。请查看您的源页面。如果您使用ASP.NET,我的解决方案很有用
我再说一遍,如果你使用ASP.NET技术,我所有的expalin都会被使用。
如果asp.net中有母版页和内容页
,并使用asp.net标记(如Lable),则在运行项目后,元素的Id将更改,并且在元素Id的前缀上可以看到内容页的Id。
例如:
<%@ Master %>
<html>
<body>
<h1>Standard Header From Masterpage</h1>
<asp:ContentPlaceHolder id="CPH1" runat="server">
<asp:Label ID="lblTest" runat="server" Text="Label"></asp:Label>
</asp:ContentPlaceHolder>
</body>
</html>
运行项目后,您会看到:
<span id="CPH1_lblTest">Label</span>
编译后,将标签更改为span标签,其Id从lblTest更改为CPH1LBLTEST。右键单击网页并选择查看源代码
现在,您应该在您的javascript中使用CPH1\u lblTest而不是lblTest。更多信息将非常有用。您能告诉我们生成HTML的服务器端代码是什么,它在本地呈现给什么,以及何时在浏览器中发布视图源代码吗?css是如何包含的?使用捆绑包?你在用什么技术?我在@Url.action上猜ASP.NET MVC。还有,你为什么要使用!重要吗?也许你的缓存有问题。尝试使用ctrl-F5在浏览器中强制刷新缓存。是的,我使用的是ASP.NET MVC,css已导入。我使用过GoogleDev工具,我可以看到访问的类在发布和调试版本中按预期添加和删除。我刚刚使用了fiddler web调试程序,当运行发布版本时,我得到了一个错误:将更新帖子。对不起,Hamid。我不明白你的建议,你能澄清一下吗?