Search code examples
asp.nettwitter-bootstrapmaster-pages

Master page isn't working


I am trying to implement a bootstrap's crousal and navbar using asp.net's master page but nothing is apearing in the pages i tried to implement master page

Master page code

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

Form on which i tried to implement master page

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

Here is the all code i am implementing but it isnt showing me any thing of Bootstrap crousal and navbar


Solution

  • You have placed image inside the asp ContentPlaceHolder which is wrong. As the name suggest It is just a place holder and anything you want to put inside it must be put in the WebForms Content tags.

    Your code should look like this:

    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>