Adding, deleting, and querying role details

Source: Internet
Author: User

Why only add, delete, and query a role? What about change?

Sorry, Microsoft does not provide the role change function in this permission management mechanism,

So there is no change. However, if you have to change it, it is also possible,

You can customize a method by using ADO. Net in this methodProgramTo rewrite a data table,

What about the properties of role,

Is stored in the 11 Data Tables automatically generated in the database registered by the website

Aspnet_roles and aspnet_usersinroles are two data tables,

Therefore, if you want to change the role (such as changing the role name), you can write SQL statements by yourself,

About Role, let's introduce a class first. The first is static class roles,

The role functions we often use are all provided by roles,

There are also roleprovider and rolemanagermodule, but these classes are rarely used,

So I don't want to introduce it (I just know what it is for sub-use, and the specific attribute method can be checked by msdn)

What is the title of a blog post? It implements the addition, deletion, and query mechanism of role, that is, adding, deleting, and searching roles,

Well, the demo below shows everything,

I will identify the important methods and attributes,

You only need to pay attention to it.

Because the example is relatively simple and does not need to be explained, let's take a look.

Code-behind

The demo is on the top. Next we will look at the demo,

Create admin, superadmin, and baobeime roles first,

Then, remove the admin and superadmin roles.

In this way, only the baobeime role is left.

As shown above, we only need to add or delete two functions,

In fact, the query is included. For example, it is a query to bind all the role to The ListBox,

The above is actually the role creation and deletion functions provided by ASP. NET Website management tools,

I will use it here.CodeWrite it once, so there is nothing unusual.

2010-2-07

 

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.