Bootstrap 母版页不工作

hsvhsicv  于 2022-12-08  发布在  Bootstrap
关注(0)|答案(2)|浏览(127)

我正在尝试使用www.example.com的母版页实现 Bootstrap 的crosial和navbarasp.net,但在我尝试实现母版页的页面中没有显示任何内容
母版页代码

<%@ 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 crosal和navbar的内容

kuhbmx9i

kuhbmx9i1#

您将图像放置在asp ContentPlaceholder中,这是错误的。顾名思义,它只是一个占位符,您要放置在其中的任何内容都必须放置在WebForms Content标记中。
您的程式码应该如下所示:
主服务器

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

网页表单

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

oaxa6hgo2#

主人:

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

相关问题