MVCでネストされたマスターページを作成しようとしています。メインマスターページには、Html.RenderPartialを使用してレンダリングされた部分ビューがあります。私のビューでメインマスターページを直接使用する場合、これは正常に機能します。この問題は、メインマスターページの子マスターページがある場合に発生します。子マスターページを使用する場合、RenderPartialメソッドは機能しません。コードは以下のとおりです。
これはRenderPartialの制限ですか?
メインマスターページ-
<%@ Master Language="VB" Inherits="System.Web.Mvc.ViewMasterPage"%>
<!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 id="Head1" runat="server">
<title></title>
<style type="text/css">
html
{
background-color:gray;
}
.column
{
float:left;
width:300px;
border:solid 1px black;
margin-right:10px;
padding:5px;
background-color:white;
min-height:500px;
}
</style>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<h1>My Website</h1>
<div class="column">
<asp:ContentPlaceHolder ID="Column1Content" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="column">
<asp:ContentPlaceHolder ID="Column2Content" runat="server">
<%Html.RenderPartial("TestControl")%>
</asp:ContentPlaceHolder>
</div>
</body>
</html>
チャイルドマスターページ-
<%@ Master Language="VB" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/ViewJob/Parent.Master" %>
<asp:Content ID="head" ContentPlaceHolderID="head" runat="server">
<asp:ContentPlaceHolder ID="head" runat="server" >
</asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="ContentPlaceHolder1" ContentPlaceHolderID="Column1Content" runat="server" >
<b>This is from the child master!!!</b>
<asp:ContentPlaceHolder ID="Column1Content" runat="server" />
</asp:Content>
<asp:Content ID="ContentPlaceHolder2" ContentPlaceHolderID="Column2Content" runat="server">
<asp:ContentPlaceHolder ID="Column2Content" runat="server" >
</asp:ContentPlaceHolder>
</asp:Content>