4.6. Permission subsystem presentation layer (Web)
Modify signin. aspx < ASP: Content ID = "Middlecolumncontent" Contentplaceholderid = "Middlecolumnzone" Runat = "Server" >
< ASP: Panel ID = "Panel1" Runat = "Server" Groupingtext = "User Logon" >
< BR />
< ASP: Login ID = "Login1" Runat = "Server" Titletext = "" >
</ ASP: Login >
</ ASP: Panel >
</ ASP: Content >
Modify roles. aspx < ASP: Content ID = "Middlecolumncontent" Contentplaceholderid = "Middlecolumnzone" Runat = "Server" >
< ASP: Panel ID = "Panel1" Runat = "Server" Groupingtext = "Role list" >
< BR />
< ASP: bulletedlist ID = "Lstroles" Runat = "Server" >
</ ASP: bulletedlist >
</ ASP: Panel >
< HR />
< ASP: Panel ID = "Panel2" Runat = "Server" Groupingtext = "Add a role" >
< BR />
Role Name: < ASP: textbox ID = "Txtrolename" Runat = "Server" > </ ASP: textbox >
< ASP: button ID = "Btnaddrole" Runat = "Server" Text = "Add a role" Onclick = "Btnaddrole_click" />
</ ASP: Panel >
</ ASP: Content >
Modify roles. aspx. CSUsing System;
Using System. Data;
Using System. configuration;
Using System. collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. webcontrols. webparts;
Using System. Web. UI. htmlcontrols;
Public Partial Class Roles: system. Web. UI. Page
{
Protected Void Page_load ( Object Sender, eventargs E)
{
If(!Page. ispostback)
{
Bindroles ();
}
}
Protected Void Btnaddrole_click ( Object Sender, eventargs E)
{
System. Web. Security. roles. createrole (txtrolename. Text );
Bindroles ();
}
Private Void Bindroles ()
{
Lstroles. Items. Clear ();
String [] Roles = System. Web. Security. roles. getallroles ();
If (Roles ! = Null )
{
Foreach ( String Role In Roles)
{
Lstroles. Items. Add (role );
}
}
}
}