如何在内容页面后添加母版页

时间:2013-07-01 00:31:21

标签: c# asp.net

这是我新添加的母版页:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Feedback.master.cs" Inherits="Login.Feedback" %>

<!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>Untitled Page</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="style1">
            <tr>
                <td height="166">
                    <asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
                    <asp:XmlDataSource ID="XmlDataSource1" runat="server" 
                        DataFile="~/App_Data/AdRotator.xml"></asp:XmlDataSource></td>
                   <td> <img alt="Welcome to Teachers Evaluation System" src="Images/welcome.png" 
                        style="width: 662px; height: 166px" /></td>
            </tr>
            <tr>
                <td valign="top">
        <asp:ContentPlaceHolder ID="bodyContent" runat="server">

        </asp:ContentPlaceHolder>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

这是我的登录页面。我希望它来自师父。我需要做出哪些改变?它给出了很多错误。另外,我不想在主文件中添加任何代码 - 我应该保留Feedback.Master.csFeedback.Master.Designer

<%@ Page Language="C#"  AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Login._Default" %>


<!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>Home Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem>Administrator</asp:ListItem>
            <asp:ListItem>Student</asp:ListItem>
            <asp:ListItem>Faculty</asp:ListItem>
            <asp:ListItem>Head of Department</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <br />

        <asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;
        <br />
        <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
&nbsp;<br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Connect" 
            Width="79px" />
&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Login" 
            Width="70px" />

    </div>
    </form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

在登录页面中,将<body>标记更改为<asp:Content runat="server" ContentPlaceHolderID="bodyContent">

然后删除其上方和下方的所有内容,并将MasterPageFile="~/Feedback.master添加到您的@Page指令中。