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