母版页不工作

Master page isn't working

我正在尝试使用 asp.net 的母版页实现 bootstrap 的 crousal 和导航栏 但是我尝试实现母版页的页面中没有任何内容

主页代码

 <%@ Master Language="C#" AutoEventWireup="true" 
CodeBehind="Survey.master.cs" Inherits="SurveySystem.Survey" %>    
<!DOCTYPE html>

 <html>
 <head runat="server">
 <title></title>
 <asp:ContentPlaceHolder ID="head" runat="server">
 </asp:ContentPlaceHolder>
</head>
 <body>
<form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="body" runat="server">
            <asp:Image ID="Image1" runat="server"  
      src="~/ProjectImage/download (2).jpg"/>
            </asp:ContentPlaceHolder>
      </div>
    </form>
 </body>
 </html>

我尝试在其上实现母版页的表单

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SignUp.aspx.cs" 
Inherits="SurveySystem.SignUp" MasterPageFile="~/Survey.Master"  %>


   <asp:Content runat="server" ID="Content1" ContentPlaceHolderID="body" >

       <h3 align="center">
            Sign Up to Create Your Survey
        </h3>
        <table >

            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label ID="Label1" runat="server" Text="First 
           Name*">
    </asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox ID="TextBoxFirstName" runat="server" 
        placeholder="First Name" class="form-control"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label  ID="Label2" runat="server" Text="Middle 
        Name"></asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox class="form-control" ID="TextBoxMiddleName" 
     runat="server" placeholder="Middle Name"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label ID="Label3"  runat="server" Text="Last Name">
     </asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox ID="TextBoxLastName" class="form-control" 
     runat="server" placeholder="Last Name"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label ID="Label5" runat="server"  Text="Email*">
      </asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox ID="TextBoxEmail" runat="server" 
     class="form-control" placeholder="Email"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label ID="Label4" runat="server" Text="Password*">
      </asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox ID="TextBoxpassword" runat="server" 
      class="form-control" TextMode="Password" placeholder="Password">
    </asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style1" colspan="2">
                    <asp:Label ID="Label6" runat="server" Text="Confirm 
        Password*"></asp:Label>
                </td>
                <td class="auto-style2">
                    <asp:TextBox ID="TextBoxConfirm" TextMode="Password" 
      runat="server" class="form-control" placeholder="Confirm Password">
    </asp:TextBox>
                </td>
            </tr>

            <tr>
                <td colspan="2">

                    <asp:FileUpload ID="UserFileUploadImage" runat="server" 
       />

                </td>
                <td class="auto-style2">
                    <asp:Image ID="UserImagUpload" class="img-rounded" 
        runat="server" Width="150px" Height="150px" />
                </td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    <asp:Button ID="ButtonSignUp" runat="server" 
    Text="SignUp" OnClick="ButtonSignUp_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    * Mendatory Fields (You Must Fill these Fields)
                </td>
            </tr>
        </table>




         </asp:Content>

这是我正在实现的所有代码,但它没有向我展示 Bootstrap crousal 和 navbar

的任何内容

大师:

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

....


<asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>

</head>

<body>
<form runat="server">
 <div class="row">
                        <div class="col-md-12">

                            <div>
                                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                                </asp:ContentPlaceHolder>
                            </div>

                        </div>
                    </div>
                    <!-- END PAGE CONTENT-->
                </div>
</form>
</body>

页数:

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageName.Master" AutoEventWireup="true" CodeBehind="PageName.aspx.cs" Inherits="ApplicationName.FolderExistsIFHave.PageName" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>Blank Page</h1>
</asp:Content>

您将图像放在 asp ContentPlaceHolder 中,这是错误的。 顾名思义它只是一个占位符,任何你想放在里面的东西都必须放在 WebForms 内容标签中。

您的代码应如下所示:

Master

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

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Image ID="Image1" runat="server" src="~/ProjectImage/download (2).jpg" />
            <asp:ContentPlaceHolder ID="body" runat="server">
                <%-- Dont write any code here --%>
            </asp:ContentPlaceHolder>
        </div>
    </form>
</body>
</html>

WebForms

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SignUp.aspx.cs" Inherits="SurveySystem.SignUp" MasterPageFile="~/Survey.Master" %>

<asp:Content runat="server" ID="Content2" ContentPlaceHolderID="head"></asp:Content>

<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="body">

    <h3 align="center">Sign Up to Create Your Survey
    </h3>
    <table>

        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label1" runat="server" Text="First Name*"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBoxFirstName" runat="server" placeholder="First Name" class="form-control"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label2" runat="server" Text="Middle Name"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox class="form-control" ID="TextBoxMiddleName" runat="server" placeholder="Middle Name"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label3" runat="server" Text="Last Name"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBoxLastName" class="form-control" runat="server" placeholder="Last Name"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label5" runat="server" Text="Email*"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBoxEmail" runat="server" class="form-control" placeholder="Email"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label4" runat="server" Text="Password*"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBoxpassword" runat="server" class="form-control" TextMode="Password" placeholder="Password"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1" colspan="2">
                <asp:Label ID="Label6" runat="server" Text="Confirm Password*"></asp:Label>
            </td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBoxConfirm" TextMode="Password" runat="server" class="form-control" placeholder="Confirm Password"></asp:TextBox>
            </td>
        </tr>

        <tr>
            <td colspan="2">

                <asp:FileUpload ID="UserFileUploadImage" runat="server" />
            </td>
            <td class="auto-style2">
                <asp:Image ID="UserImagUpload" class="img-rounded" runat="server" Width="150px" Height="150px" />
            </td>
        </tr>
        <tr>
            <td colspan="3" align="center">
                <asp:Button ID="ButtonSignUp" runat="server" Text="SignUp" OnClick="ButtonSignUp_Click" />
            </td>
        </tr>
        <tr>
            <td colspan="2">* Mendatory Fields (You Must Fill these Fields)
            </td>
        </tr>
    </table>
</asp:Content>