0

我如何让 WEBRESOURCE 在我在同一页面中有 CSS 和 C# 代码的情况下工作。. 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">
4

1 回答 1

1

您需要从页面代码中调用ClientScriptManager.GetWebResourceUrl().

查看 MSDN 了解更多信息:http: //msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getwebresourceurl

于 2013-03-05T01:23:23.957 回答