Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I did't get login page in master page.

how to get the master page in login page.


ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" MasterPageFile="~/MasterPage.master" %>


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


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


<!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></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            height: 23px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
        <table class="style1">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="User Login">
                </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label2" runat="server" Text="Username">
                </td>
                <td class="style2">
                    <asp:TextBox ID="TextBox1" runat="server">
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Password">
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server">
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnLogin" runat="server" Text="Login" />
                </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td>
                     </td>
                <td>
                     </td>
            </tr>
        </table>
        
    </div>
    </form>
</body>
</html>
Posted
Updated 2-May-12 2:09am
v3
Comments
nagendrathecoder 2-May-12 8:07am    
Your question is not clear, please explain a bit.
Keith Barrow 2-May-12 8:08am    
What do you mean by you didn't get the master page exactly?
Is the page giving an error?

Is the page unstyled (i.e. you get a login page but it is not formatted)? If this is the case you are getting the masterpage, but the stylesheet is probably not being downloaded as it is in the secured area of the site.

While adding a new page you can select to choose master page.

see this for detailed explanation and how to do it: Beginner's Tutorial on Master Pages in ASP.NET[^]

this article contains Step by step procedure to do it.
 
Share this answer
 
v2
C#
<%@ Page Language="C#" CodeBehind="Login.aspx.cs" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="True" Debug="true" Inherits="Login" %>


<asp:Content ID="cntLogin" ContentPlaceHolderID="cphLogin" runat="server">

<style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            height: 23px;
        }
    </style>


<table class="style1">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="User Login">
                </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label2" runat="server" Text="Username">
                </td>
                <td class="style2">
                    <asp:TextBox ID="TextBox1" runat="server">
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Password">
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server">
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnLogin" runat="server" Text="Login" />
                </td>
                <td>
                     </td>
            </tr>
            <tr>
                <td>
                     </td>
                <td>
                     </td>
            </tr>
        </table>

</asp:Content>
 
Share this answer
 
v3
Hi ,
try this
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>

All you need place ContentPlaceHolderID for head abd body and Determine MasterPageFile in page directive
Best Regards
M.Mitwalli
 
Share this answer
 
Your login page should be in such format :


XML
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Title="Login" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

Paste Here all the style code of master page 

</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID=ContentPlaceHolder1; Runat="Server">

code of Login Page

</asp:Content>
 
Share this answer
 
v4
In the code you have posted there are two Page Directive tags in the same page.check it once.It may be your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900