Setting the Form DefaultButton to a wizard Step Button (2.0)

J

John Mott

Hi All,

I'm trying to set the defaultbutton for a form to a button contained in a
step template for a wizard control. This is the code in PreRender:

switch (myWizard.ActiveStep.StepType) {
case WizardStepType.Start: this.Page.Form.DefaultButton =
"StartNextButton"; break;
case WizardStepType.Finish: this.Page.Form.DefaultButton =
"FinishButton"; break;
default: this.Page.Form.DefaultButton = "StepNextButton"; break;
}

I get this error:
The DefaultButton of 'form1' must be the ID of a control of type
IButtonControl

The buttons are clearly just buttons defined in the Template section of the
wizard.
Why can't it see the buttons defined in the templates?

Thanks,

John Mott
(e-mail address removed)
 
O

Olaf Rabbachin

Hi,

John said:
I'm trying to set the defaultbutton for a form to a button contained in a
step template for a wizard control. This is the code in PreRender:
[...]
I get this error:
The DefaultButton of 'form1' must be the ID of a control of type
IButtonControl

The buttons are clearly just buttons defined in the Template section of the
wizard.
Why can't it see the buttons defined in the templates?

I've seen that issue with a login-control. The simple remedy was to create
a dummy-button (visible, but width and height = 0) whose .Click-event
called the appropriate button within the login-control. You should actually
put your wizard-control into a panel and register the dummy-button as the
default button for that panel, this way you can have default-buttons for
different areas of your form.

Cheers,
Olaf
 
S

sheadog

I had the same problems with the Wizard Control. After reading 9,000
blog posts I did this for the first button on the wizard.

Page.Form.DefaultButton =
Wizard1.FindControl("StartNavigationTemplateContainerID$StartNextButton").UniqueID;

For the other pages you'll notice that the default behavior is to set
focus to the Previous button when you hit enter! Awesome built in
feature if you design your wizards to go backwards! To fix that I had
to set the values of UseSubmitBehavior.

<StepNavigationTemplate>
<asp:Button ID="StepPreviousButton"
UseSubmitBehavior="False" runat="server" CausesValidation="False"
CommandName="MovePrevious"
Text="Previous" />
<asp:Button ID="StepNextButton" UseSubmitBehavior="True"
runat="server" CommandName="MoveNext" Text="Next" />
</StepNavigationTemplate>

You've probably found a way to do this by now... but I figured I'd post
a solution anyways.

Now I'm having problems getting this to work with my Login Control
since I can't seem to figure out how to reference the submit button.

-Jennifer
 
O

Olaf Rabbachin

Hi,

Now I'm having problems getting this to work with my Login Control
since I can't seem to figure out how to reference the submit button.

haven't tried, but since ...
Page.Form.DefaultButton =
Wizard1.FindControl("StartNavigationTemplateContainerID$StartNextButton").UniqueID;

.... did the trick for the wizard-control, shouldn't an analogous or similar
approach work for the login-control as well?
When I stumbled over that behaviour I also read tons of articles, blogs and
the such, without any hint leading to a work-around or "true" solution.
Hence the simple remedy that I posted. However, my solution sure seems
inappropriate in that it actually adds a superfluous control which someone
that reads the code will have to find out about. But time's expensive and
that approach is integrated quickly ... ;-)

And - thanks for posting your remedy. Keep us posted if you find one for
the login-control too!

Cheers,
Olaf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top