Default wizard button in ASP.NET
Comments available as RSS 2.0
When you press enter/return on a wizard control in ASP.NET, the default action is to just submit the form, disregarding any buttons which were pressed. This seems pretty counter-intuitive to me – if I press enter on a form, it should be obvious I want to go ‘Next’. After two hours trying to debug an installer wondering why it seemed to work sometimes and not others I eventually tracked it down to the default button. I’m using a master page, but the principle is the same if you’re not.
The method I used uses the Page_Load event to set the default button for the form.
if(!Page.IsPostBack) { // First page, nothing clicked Master.Page.Form.DefaultButton = wzdInstall.FindControl("StartNavigationTemplateContainerID$StartNextButton").UniqueID; } else { switch(wzdInstall.ActiveStepIndex) { // set the default button to next case 0: //page has posted back but is still on page one, about to load page 2 default: Master.Page.Form.DefaultButton = wzdInstall.FindControl("StepNavigationTemplateContainerID$StepNextButton").UniqueID; break; case 1: // my wizard only had three steps, but this should be the number of steps-1 Master.Page.Form.DefaultButton = wzdInstall.FindControl("FinishNavigationTemplateContainerID$FinishButton").UniqueID; break; } }

I used the following, inspired by your code from inside the ActiveStepChanged step
hi,
I get exception error when using this code in page load function of asp.net C#.
plz let me know what should I do?
my code is exactly:
And the exception is..?