简体   繁体   English

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

[英]How to add master page after content page

this is my newly added master page: 这是我新添加的母版页:

<%@ 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>

And this is my login page. 这是我的登录页面。 I want it to derive from Master. 我希望它来自师父。 What changes do I need to make? 我需要进行哪些更改? It's giving a lot of errors. 这会带来很多错误。 Also, I don't want to add any code to Master File - should I keep Feedback.Master.cs and Feedback.Master.Designer 另外,我不想将任何代码添加到主文件中-我应该保留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>

In your login page, change your <body> tag to <asp:Content runat="server" ContentPlaceHolderID="bodyContent"> . 在登录页面中,将<body>标记更改为<asp:Content runat="server" ContentPlaceHolderID="bodyContent">

Then remove everything above and below that, and add MasterPageFile="~/Feedback.master to your @Page directive. 然后删除上面和下面的所有内容,并将MasterPageFile="~/Feedback.master添加到您的@Page指令中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM