ASP. NET & Spring. Net & nhib.pdf Best Practices (23) -- Chapter 1 permission subsystem (16)

Source: Internet
Author: User
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 );
}
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.