如何使用嵌套母版页? [英] how to use nested master page ?
问题描述
我有一个母版页面site1.master和嵌套母版页面名称nestedmasterpage1.master
当我将嵌套页面添加到内容页面时获取错误无法找到ContentPlaceHolder中的'MainContent'母版页''NestedMasterPage1.Master'
我该怎么办?
plz help
嵌套母版页----------------
<%@ Master Language =VBMasterPageFile =〜/ Site1。 MasterAutoEventWireup =falseCodeBehind =NestedMasterPage1.master.vbInherits =WebApplication2.NestedMasterPage1%>
< asp:Content ID =Content2ContentPlaceHolderID =MainContentrunat =server>
内容页面---- ---------------
<%@ Page Title =Language =vbAutoEventWireup =falseMasterPageFile =〜/ NestedMasterPage1.Master CodeBehind =report.aspx.vbInhe rits =WebApplication2.report%>
<%@ Register Assembly =Syncfusion.Grid.Grouping.Web,Version = 8.204.0.18,Culture =中性,PublicKeyToken = 3d67ed1f87d44c89
Namespace =Syncfusion.Web.UI.WebControls.Grid.GroupingTagPrefix =syncfusion%>
< asp:Content ID =Content2ContentPlaceHolderID =MainContentrunat =server>
在ASP.NET中使用嵌套母版页
你的母版页面site1.master应该有一个内容占位符您在NestedMasterPage1.Master中使用了IDMainContent
在NestedMasterPage1.Master中,您可以在MainContent Place holder中为您的内容页面使用另一个内容占位符。
你需要在嵌套的母版页中放置一个内容占位符
这样有效,你有一个内容pla母版页中的ceholder在你的嵌套母版页中说MainContent而不是
< asp:content id = Content2 contentplaceholderid = MainContent runat = server xmlns:asp = #unknown > < / asp:content >
使用
< asp:content id = Content2 contentplaceholderid = < span class =code-string> MainContent runat = server xmlns:asp = #unknown >
< asp:contentplaceholder id = MainContentNested runat = server >
< span class =code-keyword>< / asp:contentplaceholder >
< / asp:content >
现在在你的页面中引用MainContentNested而不是MainContent。
希望有帮助
尝试以下链接希望它有所帮助:)
嵌套母版页面asp.net
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">解决方案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.
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
<asp:content id="Content2" contentplaceholderid="MainContent" runat="server" xmlns:asp="#unknown"></asp:content>
use
<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
Try the below link hope it helps :)
Nested master page asp.net
这篇关于如何使用嵌套母版页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!