asp.net - 母版页图像未显示在内容页中?

标签 asp.net css visual-studio html master-pages

我有一个带有一个 div 标题的母版页。

#header
        {
             background-image: url("images/ST_ERP_2.jpg");
            background-repeat: no-repeat;
            background-position: right top;

            height: 200px;
            width: 1200px;
        } 

下面是标题div

<div id="header" >
            <h1>
                Header goes here</h1>               
</div> 

以上代码片段都在我的母版页中。

现在我有一个位于某个目录内的内容页面 (xyz.aspx)。

图像 (ST_ERP_2.jpg) 在 images 文件夹中。

现在,当我尝试在浏览器中查看页面 (xyz.aspx) 时,它不会显示我为 background-image 设置的图像它显示了一个空白的白色区域。 可能是什么问题?

注意:

  1. 我也尝试过 background-image: url("~/images/ST_ERP_2.jpg"); 但它 对我没有帮助。

  2. 我正在使用 VS2010 和 ASP.NET

主页:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%--<%@ Register Assembly="AccordionSiteMap" Namespace="FranchiseBlast.UserControls.Interface"
    TagPrefix="lb" %>--%>
<!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 id="Head1" runat="server">

    <style type="text/css">

        #wrapper
        {
            background: #FFFFFF;
            margin: 0px auto;
            width: 1200px;
            height: 1024px;
        }

        #header
        {
             background-image: url("images/ST_ERP_2.jpg");
            background-repeat: no-repeat;
            background-position: right top;

            height: 200px;
            width: 1200px;
        }

        #footer
        {
            background: #838283;
            height: 40px;
            width: 1200px;
            margin: 600px 0px;
        }
    </style>
    <title></title>
</head>
<body style="background: LightBlue">
    <form id="form1" runat="server">
    <div id="wrapper">
        <div id="header" >
            <h1>
                Header goes here</h1>
            <br />

        </div>
        <!--Header-->


 .... content place holder and etc  ......


         <div id="footer" style="clear: both">
            <h3>
                Footer goes here</h3>
        </div>
        <!--Footer-->
    </div>
    </form>
</body>
</html>

最佳答案

尝试用这个替换背景图像:

background-image: url(<%=ResolveClientUrl("~/images/ST_ERP_2.jpg")%>);

关于asp.net - 母版页图像未显示在内容页中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11667521/

相关文章:

asp.net - OCIEnvCreate 失败,返回代码为 -1,但错误消息文本不可用。在数据对象支持(721,6)

html - 获取像 SVG 动画路径一样的 CSS 动画

windows - VS2008会编译兼容Windows 7的二进制文件吗

c# - 无需等待即可调用异步方法 #2

asp.net - asp.net 中用于特殊土耳其字符的字符集 utf-8

asp.net - session 变量在 paypal 后变空并在按 ctrl+f5 后接收值

表格中的 HTML 输入需要一些额外的空间——CSS

css - 表单元素低于预期。不知道为什么

javascript - "Windows Phone HTML5 App"和 "Javascript Windows Store Project"之间的区别

c# - Visual Studio 2015 中的 1.0.0-beta