2009-06-03 20 views

答えて

10

イエップ。私はちょうどこれについてのブログ記事を見た:http://jeffreypalermo.com/blog/asp-net-mvc-and-the-templated-partial-view-death-to-ascx/

非常にクールなもの。

我々は含まれており、そのようなサイト全体のマークアップ、標準から別々のレイアウトするために、頻繁に入れ子になったマスターページを使用
+0

あなたはそれに私を打ちます。良い投稿です。 – aleemb

+1

ちょうど私のつぶやきに追いつく必要があるように見えます。 elijahmanor:@jeffreypalermo #tech #aspnetmvc http://bit.ly/ctKii "ASP.NET MVCとテンプレート化された部分ビュー(ASCXへの死)" ありがとう! – OneSmartGuy

40

Site.Master:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage<PageViewModel>" %> 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    <meta name="language" content="en"> 
    <title><asp:ContentPlaceHolder ID="Title" runat="server"><%= Model.Page.Title %></asp:ContentPlaceHolder></title> 

    <% Html.RenderPartial("Head"); %> 

    <meta name="robots" content="index, follow"> 
    <meta name="robots" content="noodp"> 
    <asp:ContentPlaceHolder ID="ExtraHead" runat="server"></asp:ContentPlaceHolder> 
</head> 
<body > 

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

</body> 
</html> 

はその後、サイトを使用して別のマスターを持っています管理組織のビー玉、

Standard.Master:

<%@ Master Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewMasterPage<PageViewModel>" MasterPageFile="Site.Master" %> 
<asp:Content ContentPlaceHolderID="ExtraHead" runat="server"> 
    <asp:ContentPlaceHolder ID="ExtraHead" runat="server"></asp:ContentPlaceHolder> 
</asp:Content> 

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


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


</asp:Content> 
+2

いい例、マスターテンプレートの各レベルで同じContentPlaceHolder IDを使用することができます。 – lambacck

+0

@リチャード:Inherits = "System.Web.Mvc.ViewMasterPage "は私の場合はエラーを返しますが、代わりにInherits = "System.Web.Mvc"を使用しました。 ViewMasterPage "とそれがうまくいきました。理由は説明できますか?実際にあなたの答えは優れています。 –

+0

非常に良い。ありがとう! – Ricky

関連する問題