In our application system, data in user tables of Asp.net 2.0 often cannot meet our needs, and more data needs to be added. One possible solution is to use profile, the more common solution is to add data to our own table in createuserwizard.
The primary key in the table designed by the user management system in combination with Asp.net 2.0 to save additional user information is the foreign key of the User table ID. You can obtain the ID from the membershipuser attribute provideruserkey. use the createuserwizard oncreateduser event. in this event, you can use the getuser method of the membership class to obtain the currently created user membershipuser.
Membershipuser user = membership. getuser = (mycreateuserwizar. username );
You can use the username attribute of createuserwizard to obtain the registered username. When you create a user membershipuser object, you can use provideruserkey to obtain the user's primary key value (a guid value ):
In the oncreateduser event of createuserwinard, you can obtain the additional user information you want to add and insert the value of provideruserkey into your own database table. The following is an example of how to use it:
Protected void createuserwizard1_createduser (Object sender, system. eventargs E)
{
Membershipuser user = membership. getuser (createuserwizard1.username );
If (user! = NULL)
Throw new applicationexception ("user not found .");
Guid userid = (guid) user. provideruserkey;
// Obtain the additional user registration information in the createuserwizard Control
Textbox mydata = createuserwizard1.createuserstep. contenttemplatecontainer. findcontrol ("textbox1") as textbox;
Userinfo = new userinfo ();
Userinfo. ID = userid;
Userinfo. QQ = mydata. text;
......
This. addmydatatomydatasource (userinfo );
}
Private void addmydatatomydatasource (userinfo mydata)
{
// Add data to your database table
}
Membership in GardenArticle:
ASP. NET 2.0 membership
Asp.net 2.0 user management function structure
Membership settings
In ASP. NET 2.0, how does one use membership?
Membership Learning (4)-custom membershipprovider [xgluxv]
Membership Learning (3) Introduction to membership providers [xgluxv] membership Learning (2) Introduction to membership [xgluxv] membership Learning (1) Introduction to membership [xgluxv]
Membership: It's not easy to love you.