1

I added custom questions to the CreateUserWizard control and created an additional table in the ASPNETDB database called aspnet_UserInfo. How do I sql insert into table when the [Create User] button is clicked like they do for the username? Or do i just create the inserts separately on the button postback?

And also where is the sql statements that write the user name and password from the CreateUserWizard control?

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
Troy Mitchel
  • 1,790
  • 11
  • 50
  • 88

1 Answers1

1

There are a couple of events that occur while your creating a new user with the CreateUserWizard control (specifically the FinishButtonClick and the CreatedUser events). You could handle either one of those events and do your custom SQL insert into your aspnet_UserInfo table in the event handler.

This MSDN tutorial is a great resource for customizing the CreateUserWizard process.

I don't know of a way to find out what specific SQL statements are executed when the library functions are called to create a new user. That doesn't mean there isn't a way though, I just don't know it =)

Addition (based on comments): Considering your use-case, look in the code-behind for your "Register.aspx" file. There is a line in there (by default) that looks like this:

FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)

Just delete that line and you'll be good - your Admin will continue to be logged in as himself after creating the new user.

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
  • Thanks. I will look into the link. I also need to re-populate user account information because there is an administrator to the Web Application who will Assign UserNames and Passwords. I'n new at Asp.Net so it seems a little tricky. – Troy Mitchel Oct 21 '11 at 13:45
  • I want the CreateUser button to create the user but not log them in. Is that possible? – Troy Mitchel Oct 21 '11 at 14:01
  • @tszoro I've updated the answer with one way of accompishing that. – Josh Darnell Oct 21 '11 at 14:18
  • Thank you. That did indeed work however I would like to keep the Admin still signed in. Basically the Admin signs in, creates new user, and admin still needs to stay signed in after creating user. Not quite sure on this step. – Troy Mitchel Oct 21 '11 at 15:45
  • @tszoro Oops, didn't realize that was what you were doing. Updating the question with a better option. – Josh Darnell Oct 21 '11 at 16:10
  • Thank you. That worked out. And after i commented out the line i had to Response.Redirect("../Admin/MyPage.aspx") and all is well. – Troy Mitchel Oct 21 '11 at 18:34
  • @tszoro Awesome! Glad I could help. If you don't mind, [upvote or accept](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) this answer since it worked for you =) – Josh Darnell Oct 21 '11 at 18:41