Last post Apr 16, 2012 03:46 AM by Steven Cheng - MSFT
Apr 13, 2012 12:19 PM|TonyLoco23|LINK
I want users to enter additional info such as phone numbers, company name, etc. when they register for a website.
What is the best way to do this?
I suppose I should store all the extra info in a seperate table from the regular asp.net membership table right? Because I do not want to mess with the ready made table.
At first I thought about simply building my own create user page from scratch, and then simply call "Membership.CreateUser" after storing all the extra fields in my own table. The only problem with this is that it will create the user but will not actually
log the user in right? How could I programmatically log the user in after I call "Membership.CreateUser"?
The other approach would be to place a CreateUserWizard control on a page and simply add some additional textboxes to the page that will store the additional fields. The only problem with that approach is I want the additional fields to be required not optional,
but I could not work out a way to NOT create the new account when the user presses the create account button but has not filled out the additional fields. I tried using regular expression validators but that did not work, it still went ahead and created the
user anyway when the additional fields were empty.
Apr 14, 2012 03:42 AM|Primillo|LINK
Check out how is done here (Complete sample - Source code download):
Used as reference.
Apr 16, 2012 03:46 AM|Steven Cheng - MSFT|LINK
If you want to programmtically perform "login" operation in code, you can use the "FormsAuthentication" class.
This class contains the methods such as "SetAuthCookie", "RedirectFromLoginPage(String, Boolean)" which can help generate the authentication ticket for a specified username. Actually, the username is exactly the one used by membership provider later. You
can take a look at the following article for more details about ASP.NET forms authentication:
#Explained: Forms Authentication in ASP.NET 2.0
And as for the "CreateUserwizard", you should be able to customize it by specifying the complete HTML markup for each step yourself. And if you want to add additional textboxes and validation controls, don't forget to specify a "validationGroup" for them
since ASP.NET webform page will perform validation checking(before postback) based on the "validationGroup" you specified. Here are some reference for your information:
#How to: Customize the ASP.NET CreateUserWizard Control
#Specifying Validation Groups
#Adding additional controls to CreateUserWizard (CUW) Control