我是asp.net的新手,我目前处于master.pages的基础。
我正在测试如何将图像标题放到我的母版页。
这是我的master.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="master.master.cs" Inherits="master" %>
<!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>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
这是Default.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
当我运行它时,我放入master.master的imageHeader没有出现。
非常感谢你们的任何帮助。
感谢您的帮助!
答案 0 :(得分:3)
如果您要在所有页面中查看图像,请从MasterPage中的ContentPlaceHolder移出图像
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
TO:
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>