-3

I already made update.aspx page and view.aspx page now I want to assign master page that to these pages...can someone help me out ?

Brinda
  • 7
  • 6
  • You mean, you've designed the whole page and now you want to assign the masterpage to it? If yes, this is the wrong approach to the master page concept. You have to map the master page to the child page and then design the content blocks. – Techie Jan 28 '16 at 09:46
  • Possible duplicate of [How to assign a master page to a existing .aspx page?](http://stackoverflow.com/questions/2273368/how-to-assign-a-master-page-to-a-existing-aspx-page) – Ciara Jan 28 '16 at 11:26

2 Answers2

0

Create new master page names Site.Master, move everything you want from update.aspx into master, so probably Head section html content, and then in the body put the placeholder:

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

Now when "shared" master content is moved from your update.aspx/view.aspx, you just need to wrap everything that's left in those pages into this:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">  
your update.aspx page content
</asp:Content>

In first line of your page you should have something like <%@ Page ... attributes ... %>, add new attribute that points to the master page: MasterPageFile="~/Site.Master"

For the reference, create new WebForms project and you'll get few sample pages. See how should a HTML content in the master page look like, and how to wrap page content of you aspx page.

End result should look something like this:
Site.Master

<html><head>...</head>
<body>
    some master body html content
    <asp:ContentPlaceHolder runat="server" ID="MainContent" />
    more html here
</body>
<html>

Then the page:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">  
    your update.aspx page content
</asp:Content>
Hrvoje Hudo
  • 8,994
  • 5
  • 33
  • 42
0

i suppose your master page is Main.Master the first step in the update.aspx page and view.aspx page (at the top ) make MasterPageFile attribute = "~/Main.Master" this is the code

<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="update.aspx.cs" 

the second step remove the head and title and body and html tags from the update.aspx page and view.aspx page

and put tow content two content place holders (the same in the master page) in your pages(update.aspx and view.aspx)

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

the previous content place holder represents the head of this page you can put in it any css or java script code or references

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

second placeholder represents the body of this page you can put in it the body of your page(update.aspx)