Bagikan melalui


LoginView.RoleGroups Properti

Definisi

Mendapatkan kumpulan grup peran yang mengaitkan templat konten dengan peran tertentu.

public:
 virtual property System::Web::UI::WebControls::RoleGroupCollection ^ RoleGroups { System::Web::UI::WebControls::RoleGroupCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.Themeable(false)]
public virtual System.Web.UI.WebControls.RoleGroupCollection RoleGroups { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.Themeable(false)>]
member this.RoleGroups : System.Web.UI.WebControls.RoleGroupCollection
Public Overridable ReadOnly Property RoleGroups As RoleGroupCollection

Nilai Properti

Objek RoleGroupCollection yang berisi templat grup peran yang ditentukan.

Atribut

Contoh

Contoh kode berikut menunjukkan penggunaan RoleGroups koleksi. AnonymousTemplate Karena properti dan LoggedInTemplate tidak diatur, konten hanya ditampilkan untuk pengguna yang termasuk dalam peran dengan templat konten yang ditentukan.

<%@ 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">
</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">
                <RoleGroups>
                    <asp:RoleGroup Roles="author">
                        <ContentTemplate>
                            <ul>
                                <li>Add a new article.</li>
                                <li>Review editorial changes.</li>
                                <li>View article requests.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                    <asp:RoleGroup Roles="editor">
                        <ContentTemplate>
                            <ul>
                                <li>Review articles.</li>
                                <li>Submit edited article.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                    <asp:RoleGroup Roles="publisher">
                        <ContentTemplate>
                            <ul>
                                <li>Make article request.</li>
                                <li>Publish reviewed article.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                </RoleGroups>
            </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">
</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">
                <RoleGroups>
                    <asp:RoleGroup Roles="author">
                        <ContentTemplate>
                            <ul>
                                <li>Add a new article.</li>
                                <li>Review editorial changes.</li>
                                <li>View article requests.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                    <asp:RoleGroup Roles="editor">
                        <ContentTemplate>
                            <ul>
                                <li>Review articles.</li>
                                <li>Submit edited article.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                    <asp:RoleGroup Roles="publisher">
                        <ContentTemplate>
                            <ul>
                                <li>Make article request.</li>
                                <li>Publish reviewed article.</li>
                            </ul>
                        </ContentTemplate>
                    </asp:RoleGroup>
                </RoleGroups>
            </asp:LoginView>
        </form>
    </body>
</html>

Keterangan

Properti RoleGroups berisi templat konten yang terkait dengan berbagai peran di situs Web. Koleksi dalam RoleGroups properti dicari dalam urutan templat didefinisikan dalam sumber. Templat grup peran pertama yang cocok ditampilkan kepada pengguna. Jika pengguna adalah anggota lebih dari satu peran, templat grup peran pertama yang cocok dengan salah satu peran pengguna digunakan. Jika lebih dari satu templat dikaitkan dengan satu peran, hanya templat pertama yang ditentukan yang akan digunakan.

Jika pengguna yang masuk bukan milik peran apa pun yang terkandung dalam kumpulan grup peran, situs menampilkan templat konten yang ditentukan dalam LoggedInTemplate properti . Pengguna anonim tidak pernah ditampilkan templat apa pun yang terkandung dalam RoleGroups koleksi.

Anda harus mengonfigurasi manajemen peran untuk menggunakan RoleGroups properti untuk menentukan templat berdasarkan peran pengguna di situs Web. Untuk informasi selengkapnya, lihat Memahami Manajemen Peran.

Properti ini tidak dapat diatur oleh tema atau tema lembar gaya. Untuk informasi selengkapnya, lihat ThemeableAttribute dan ASP.NET Tema dan Kulit.

Berlaku untuk

Lihat juga