如何在同一页面中拥有CSS和C#代码的情况下使WEBRESOURCE正常工作。。 CSS块中的webresource表示未声明“WebResource”。由于其保护级别,它可能无法访问。
我已将[assembly: WebResource("Common.AdResources.tick.png", "image/png")]
添加到程序集中,并将png文件的构建操作设置为嵌入资源
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.selling_points_title_row
{
font-weight:bold;
font-family:arial;
font-size:14px;
width: 250px;
}
.bui, .con { color: #636B3B; }
.veh { color: #D4541D; }
.selling_points_header_row
{
background-image: url('<%= WebResource("Common.AdResources.tick.png")%>');
background-repeat: no-repeat;
font-weight:bold;
font-family:arial;
font-size:14px;
width: 250px;
padding-left: 30px;
}
.selling_points_content_row
{
font-family:trebuchet ms;
font-size:12px;
color: #333333;
width: 250px;
padding-left: 30px;
}
hr { color: #cccccc; }
</style>
<script type="text/VB" runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Select Case Session("type")
Case Is = "V"
vPoints.Visible = True
Case Is = "B"
bPoints.Visible = True
Case Is = "C"
cPoints.Visible = True
Case Else
'Don't show anything
End Select
End Sub
</script>
</head>
<body>
<asp:Panel id="vPoints" runat="server" visible="False">
<asp:Panel id="bPoints" runat="server" visible="False">
<asp:Panel id="cPoints" runat="server" visible="False">
答案 0 :(得分:1)
在页码内,您需要拨打ClientScriptManager.GetWebResourceUrl()
。
查看MSDN以获取更多信息:http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getwebresourceurl