0

I almost feel bad asking this stupid question, just upgraded to VS2012 from VS2008 and I started out by create a new Web Forms Application, and bang there you go a bunch of files and folders created. When I view the Register.aspx page, there's this line:

<asp:Button runat="server" CommandName="MoveNext" Text="Register" />

and when I run this application, it actually works, it creates a local DB and the user are inserted into that DB.

But HOW? I see no click events, I see no function in the code behind handling the MoveNext command, is this some kinda of new way of handling events? Where does the magic happen? Thank you guys

Mike Zhang
  • 62
  • 8

2 Answers2

2

It's all part of the CreateUserWizard control. If you disassemble that class, you'll find a bunch of code that knows how to hook up to your markup. My guess is somewhere in there is something that attaches the MoveNext command to an event handler inside that user control.

When your button does a postback on the page, the lifecycle for the control is executed, so somewhere in that lifecycle is all the work.

Joe Enos
  • 39,478
  • 11
  • 80
  • 136
2

It seems like a bit of magic but it is part of the ASP.NET 4.5 Framework. It is the CreateUserWizard control on Register.aspx, there is an attribue called OnCreatedUser that wires up the code behind "click" event you are looking for. Should be called RegisterUser_CreatedUser.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.createuserwizard.oncreateduser.aspx

Brian Ogden
  • 18,439
  • 10
  • 97
  • 176