locked
Comment utiliser la page maître imbriquée RRS feed

  • Discussion générale

  • Le code suivant montrera comment implémenter la page maître imbriqué étape par étape :

     

    code de balisage parent.master :

    <% @ Master Language="C#" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html> 
    <head id="Head1" runat="server"> 
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="Form1" runat="server"> 
        <div>
            <h1> 
                Parent Master</h1> 
            <p style="font: color=red"> 
                This is parent master content.</p>
            <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
        </div> 
        </form> 
    </body> 
    </html>

     

     

     

    Code de balisage child.master: 

    <%@ Master Language="C#" MasterPageFile="~/parent .master" %> 
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 
        <asp:Panel runat="server" ID="panelMain" BackColor="lightyellow"> 
            <h2> 
                Child master</h2> 
            <asp:Panel runat="server" ID="panel1" BackColor="lightblue"> 
                <p> 
                    This is child master content.</p> 
                <asp:ContentPlaceHolder ID="ChildContent1" runat="server" /> 
            </asp:Panel> 
            <asp:Panel runat="server" ID="panel2" BackColor="pink"> 
                <p> 
                    This is child master content.</p> 
                <asp:ContentPlaceHolder ID="ChildContent2" runat="server" /> 
            </asp:Panel>
            <br /> 
        </asp:Panel> 
    </asp:Content>

     

     

    Code de balisage child.aspx:

    <%@ Page Language="C#" MasterPageFile="~/child.master" %> 
    <asp:Content ID="Content1" ContentPlaceHolderID="ChildContent1" runat="server"> 
        <asp:label runat="server" id="Label1" text="Child label1" font-bold="true" /> 
        <br /> 
    </asp:Content> 
    <asp:Content ID="Content2" ContentPlaceHolderID="ChildContent2" runat="server"> 
        <asp:label runat="server" id="Label2" text="Child label2" font-bold="true" /> 
    </asp:Content>

     

     

    Pour plusieurs informations, visitez la page Foire aux Questions – ASP.NET

     

     

    Appel à contribution ! http://social.msdn.microsoft.com/Forums/fr-FR/vbasicfr/thread/ff4910bf-dca4-4664-b01e-b58bd860a643
    jeudi 8 avril 2010 14:53
    Modérateur