다음을 통해 공유


RoleGroup.ContentTemplate 속성

정의

이 역할 그룹과 연결된 내용 템플릿을 가져오거나 설정합니다.

public:
 property System::Web::UI::ITemplate ^ ContentTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.LoginView))]
public System.Web.UI.ITemplate ContentTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.LoginView))>]
member this.ContentTemplate : System.Web.UI.ITemplate with get, set
Public Property ContentTemplate As ITemplate

속성 값

ITemplate

이 역할 그룹과 연결된 ITemplate입니다. 기본값은 null입니다.

특성

예제

다음 코드 예제에는 동적으로 콘텐츠 템플릿을 만듭니다.

<%@ Page Language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    private class CustomTemplate : ITemplate
    {
        public void InstantiateIn(System.Web.UI.Control container)
        {
            LoginName ln = new LoginName();
            LoginStatus ls = new LoginStatus();
            Literal lc = new Literal();
        
            lc.Text = "<br />";
            ln.FormatString = "Welcome, {0}. This line is from the template.";
        
            container.Controls.Add(ln);
            container.Controls.Add(lc);
            container.Controls.Add(ls);
        }
    }
        
    void Page_Load(Object sender, EventArgs e)
    {
        // <Snippet2>
        RoleGroup rg = new RoleGroup();
        rg.ContentTemplate = new CustomTemplate();
        // <Snippet3>
        String[] RoleList = {"users"};
        rg.Roles = RoleList;
        // </Snippet3>
        RoleGroupCollection rgc = LoginView1.RoleGroups;
        rgc.Add(rg);
        // </Snippet2>
    }

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:LoginView id="LoginView1" runat="server">
                <AnonymousTemplate>
                    You are not logged in.<br />
                    <asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus>
                </AnonymousTemplate>
                <LoggedInTemplate>
                    You are logged in as
                    <asp:LoginName id="LoginName1" runat="server" />. This message is not from the template.<br />
                    <asp:LoginStatus id="Loginstatus2" runat="server"></asp:LoginStatus>
                </LoggedInTemplate>
            </asp:LoginView>
        </form>
    </body>
</html>
<%@ Page Language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    Private Class CustomTemplate
        Implements ITemplate

        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
            Implements System.Web.UI.ITemplate.InstantiateIn
            Dim ln As New LoginName
            Dim ls As New LoginStatus
            Dim lc As New Literal

            lc.Text = "<br />"
            ln.FormatString = "Welcome, {0}. This line is from the template."

            container.Controls.Add(ln)
            container.Controls.Add(lc)
            container.Controls.Add(ls)

        End Sub
    End Class

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        ' <Snippet2>
        Dim rg As New RoleGroup
        rg.ContentTemplate = New CustomTemplate
        ' <Snippet3>        
        Dim RoleList(1) As String
        RoleList(0) = "users"
        ' </Snippet3>

        rg.Roles = RoleList

        Dim rgc As RoleGroupCollection = LoginView1.RoleGroups
        rgc.Add(rg)
        ' </Snippet2>
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:LoginView id="LoginView1" runat="server">
                <AnonymousTemplate>
                    You are not logged in.<br />
                    <asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus>
                </AnonymousTemplate>
                <LoggedInTemplate>
                    You are logged in as
                    <asp:LoginName id="LoginName1" runat="server" />. This message is not from the template.<br />
                    <asp:LoginStatus id="Loginstatus2" runat="server"></asp:LoginStatus>
                </LoggedInTemplate>
            </asp:LoginView>
        </form>
    </body>
</html>

설명

ContentTemplate 속성이 역할 그룹의 구성원 인 사용자에 게 표시 되는 콘텐츠를 포함 합니다.

적용 대상