Default Button

J

JJ

What trouble I'm having setting default buttons on a page (with a master
page).

I got around doing it on a page basis by calling the
SetWizardDefaultButton() routine [see below] from page load. Notice how
messy it looks because I could not find the required button any other way
but by using the id it is given in the source code. I tried every
combination of nested 'findcontrol' methods I could think of, but none
worked??!! It seems to be impossible if the button generated on the fly, as
it seems to be in a wizard control. Is there a simpler and tidier way of
doing this?

My main issue here is how to do in from a custom control? If I am writing a
login control that will be in the corner of my master page, I want to "set
login button as default button if no other control on the page wants to do
the same". The problem is that the login button is again, generated on the
fly as its in a loginview control. This time using the source codes
generated id doesn't seem to work at all. What am I doing wrong??


Routine (that works even if it is untidy) that sets the default button. This
is called in the page load of a page derviced from the master page. But how
would I do the same for a control that is placed on either a page or the
master page itself?:
protected void SetWizardDefaultButton()

{

Control theButton;

int StepIndex = CreateUserWizard1.ActiveStepIndex;

if (StepIndex == 0)

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$__CustomNav0$btn_CreateUserButton");

}

else

{

theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$CompleteStepContainer$ContinueButton");

}

Master.Page.Form.DefaultButton = theButton.UniqueID;

}
 
J

JJ

also, how would you set a default button dynamically? i.e. if there are two
controls on a page with input fields and submit buttons, and a user clicks
in one of the input fields, how could you ensure that the deafult button was
that of the control they were currently using.

This functionality is really basic stuff, yet I can't find a solution that
works for wizards etc anywhere. There must be someone out there that knows a
solutions to this?

JJ
 

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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top