Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a master page site1.master and a nested master page nage name nestedmasterpage1.master
when i'm add nested page to a content page get error Cannot find ContentPlaceHolder 'MainContent' in the master page '/NestedMasterPage1.Master'
what me should to do?
plz help


nested master page----------------
<%@ Master Language="VB" MasterPageFile="~/Site1.Master" AutoEventWireup="false" CodeBehind="NestedMasterPage1.master.vb" Inherits="WebApplication2.NestedMasterPage1" %>


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








content page-------------------
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/NestedMasterPage1.Master" CodeBehind="report.aspx.vb" Inherits="WebApplication2.report" %>

<%@ Register Assembly="Syncfusion.Grid.Grouping.Web, Version=8.204.0.18, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89"
Namespace="Syncfusion.Web.UI.WebControls.Grid.Grouping" TagPrefix="syncfusion" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
Posted

Using Nested Master Pages in ASP.NET

You Master page site1.master should have a content place holder with id "MainContent" as you have used it in your NestedMasterPage1.Master

In NestedMasterPage1.Master you can use another content place holder within MainContent Place holder for your content page.
 
Share this answer
 
v3
Comments
neeraj_ 21-Aug-14 7:40am    
thanks for your kind response but plz check what's wrong with my code if be possible
Gupta Poonam 21-Aug-14 7:50am    
Have improved my answer. Hope it will help you out
You need to put a content placeholder in the nested master page

So effectively, you have a content placeholder in master page say "MainContent" then in your nested master page instead of

C#
<asp:content id="Content2" contentplaceholderid="MainContent" runat="server" xmlns:asp="#unknown"></asp:content>


use

C#
<asp:content id="Content2" contentplaceholderid="MainContent" runat="server" xmlns:asp="#unknown">
 <asp:contentplaceholder id="MainContentNested" runat="server">
            </asp:contentplaceholder>

</asp:content>


Now in your page refer to MainContentNested instead of MainContent.

Hope that helps
 
Share this answer
 
Comments
Gupta Poonam 21-Aug-14 8:00am    
Thanks.. I was trying to explain/express the same. But I'm not a good writer
MT_ 21-Aug-14 11:19am    
That's how we too learn :-) In such cases, I believe its best to write small code snippet rather than trying to explain.
neeraj_ 22-Aug-14 2:16am    
sir its showing error
MainContentNested object refrence is not set to an instanceof an object
Try the below link hope it helps :)
Nested master page asp.net
 
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