|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
Roles.RoleExists 메서드
네임스페이스: System.Web.Security
어셈블리: System.Web(System.Web.dll)
매개 변수
- roleName
- 형식: System.String
데이터 소스에서 검색할 역할의 이름입니다.
| 예외 | 조건 |
|---|---|
| System.ArgumentNullException | |
| System.ArgumentException | |
| System.Configuration.Provider.ProviderException |
보안 정보 |
|---|
<%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Security" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> string[] rolesArray; public void Page_Load(object sender, EventArgs args) { if (!IsPostBack) { // Bind roles to GridView. rolesArray = Roles.GetAllRoles(); RolesGrid.DataSource = rolesArray; RolesGrid.DataBind(); } } public void CreateRole_OnClick(object sender, EventArgs args) { string createRole = RoleTextBox.Text; try { if (Roles.RoleExists(createRole)) { Msg.Text = "Role '" + Server.HtmlEncode(createRole) + "' already exists. Please specify a different role name."; return; } Roles.CreateRole(createRole); Msg.Text = "Role '" + Server.HtmlEncode(createRole) + "' created."; // Re-bind roles to GridView. rolesArray = Roles.GetAllRoles(); RolesGrid.DataSource = rolesArray; RolesGrid.DataBind(); } catch (Exception e) { Msg.Text = "Role '" + Server.HtmlEncode(createRole) + "' <u>not</u> created."; Response.Write(e.ToString()); } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Sample: Create Role</title> </head> <body> <form runat="server" id="PageForm"> <h3>Create a Role</h3> <asp:Label id="Msg" ForeColor="maroon" runat="server" /><br /> Role name: <asp:TextBox id="RoleTextBox" runat="server" /> <asp:Button Text="Create Role" id="CreateRoleButton" runat="server" OnClick="CreateRole_OnClick" /> <br /> <asp:GridView runat="server" CellPadding="2" id="RolesGrid" Gridlines="Both" CellSpacing="2" AutoGenerateColumns="false" > <HeaderStyle BackColor="navy" ForeColor="white" /> <Columns> <asp:TemplateField HeaderText="Roles" > <ItemTemplate> <%# Container.DataItem.ToString() %> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
보안 정보