Click here to Skip to main content
16,010,022 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have used Master Page and from that created content page and i am adding some header and some designs to master file . As i want to show that design including header to all other aspx page i have created but don't know how to link all those pages.I am using Master page and Content page for first time,so if any one can help me it would be very helpful

What I have tried:

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

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

MASTER PAGE
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>Login Page</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/custom.css" rel="stylesheet" />
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body style="padding-top:0px;">
      <header>
        <div class="container">
            <div class="col-lg-4">
                <img src="company-logo.png" />
            </div>
            <div class="col-lg-8">
                <div class="top-nav">
                    <nav class="navbar pull-right">
                        <ul class="nav navbar-nav">
                          <li class="active"><a href="#">Home</a></li>
                          <li><a href="#">About US</a></li>
                          <li><a href="#">Contact Us</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
    </header>

    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>
Posted
Updated 29-Jun-17 14:16pm

Right click on your solution explorer. Add Master page, designed it as your requirement
Than when ever you add another .aspx page at that time Add new item dialog box there are checked select master page checkbox


check the design of that page if u used login details there are content place holder master checked it.

than your child page coding in
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
 
Share this answer
 
v2
Quote:
I am using Master page and Content page for first time


Have you gone through these articles?

Walkthrough: Creating and Using ASP.NET Master Pages
Beginner's Tutorial on Master Pages in ASP.NET

There plenty of articles to refer in the web. Please try to do a simple search at google.
 
Share this answer
 
Comments
Member 11644373 30-Jun-17 3:30am    
Thank you that's what i needed

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