【发布时间】:2018-12-03 03:54:18
【问题描述】:
我在 VS 2008 中创建了一个简单的 Web 应用程序项目。我在其中添加了一个母版页。然后我添加了两个面板。在每个面板中,我添加了一个 ContentPlaceHolder。我为每个 ContentPlaceHolder 添加了一个 ContentPage。
当我使用 Vs 2008 内部网络服务器运行它时,没有显示任何内容持有者页面。有什么帮助吗?我怀疑我做错了什么。
谢谢。
代码如下:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication5.Site1" %>
<!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">
<asp:Panel ID="Panel1" runat="server" Height="300px" Width="200px" Style="z-index: auto;
left: 0px; top: 0px; position: absolute">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="300px" Width="200px" Style="z-index: auto;
left: 205px; top: 0px; position: absolute">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
</form>
</body>
</html>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication5.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Content Page 1
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication5.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
Content Page 2
</asp:Content>
【问题讨论】:
-
您能否向我们展示母版页和基于该母版页的内容页的 ASPX 标记??
-
这个问题没有用,除非你指定标记。
-
您的代码中的所有内容似乎都已准备就绪。当您运行应用程序时,它会转到 WebForm1.aspx 还是 WebForm2.aspx?或者您是否将其转到 default.aspx 之类的其他页面?
-
我已经尝试了所有三个并得到相同的结果。它只显示一个 ASP 页面。
标签: asp.net