我正在創建一個有兩個ContentPlaceHolders的母版頁。 ContentPlaceHolders1用於存在超鏈接的菜單,而在ContentPlaceHolders3的其他ContentPlaceHolders中,所選超鏈接將打開其頁面。問題是菜單在左邊的畫布上,但是當我點擊其中一個超鏈接時,頁面將在ContentPlaceHolders3中打開,但是ContentPlaceHolders1中的整個菜單消失。 picture.aspx和sample.aspx是要在ContentPlaceHolder3中打開的頁面。從項目點擊contentplaceholder消失項目
這裏是不同的頁面代碼:
admin_panel.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="admin_panel.master.cs" Inherits="admin_panel" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table style="font-family: Arial">
<tr>
<td colspan="2" style="width: 800px; height: 80px; background-color: #3399FF; text-align: center">
<h1>WebSite Header</h1>
</td>
</tr>
<tr>
<td style="height: 500px; background-color: #66FFFF; width: 150px">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
<td style="height: 500px; background-color: #9999FF; width: 650px">
<h3>Content</h3>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
pictures.aspx:
<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="pictures.aspx.cs" Inherits="pictures" MasterPageFile="~/admin_panel.master"%>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:Image ID="Image1" runat="server" Height="200px" />
<asp:Image ID="Image2" runat="server" Height="200px" />
<asp:Image ID="Image3" runat="server" Height="200px" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</asp:Content>
樣本:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sample.aspx.cs" Inherits="sample" MasterPageFile="~/admin_panel.master"%>
<asp:Content ID="nil" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" style="height: 26px" />
</div>
</asp:Content>
admin.aspx :
<%@ Page Title="" Language="C#" MasterPageFile="~/admin_panel.master" AutoEventWireup="true" CodeFile="admin.aspx.cs" Inherits="admin" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server" >
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/pictures.aspx" runat="server">Click Me</asp:HyperLink><br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/sample.aspx" runat="server">Click Me 2...</asp:HyperLink>
</asp:Content>