0
我如何获得WEBRESOURCE在同一页面内有CSS和C#代码的情况下工作。。 CSS块中的webresource表示'WebResource'未被声明。由于其保护级别,它可能无法访问。aspx网络资源的问题
我已经添加[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">
Page.ClientScript.GetWebResourceUrl(Me.GetType(), “Common.AdResources.tick.png”) 尝试,但在运行时,它抛出一个异常,说未找到资源 – Chief 2013-03-05 01:28:20
资源不太可能嵌入页面的自己类型中,因为页面的类型将处于动态编译的程序集中。您需要传入包含Web资源的程序集中的类型。要仔细检查它,可以打印出Me.GetType()。Assembly.CodeBase,然后将.NET Reflector(或ILSpy)指向DLL,并查看该资源是否真的存在,并使用该名称。 – Eilon 2013-03-05 03:12:18
我签入了程序集,事实证明没有名称为“tick”的资源。为什么会发生这种情况,这种资源在哪里? – Chief 2013-03-05 04:31:09