Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 26th, 2006, 03:43 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Setting the DefaultButton Within a Wizard Control

Hi All

This is sort of an extension of a previous posting of mine but felt that it is worthy of a separate string...

I have a registration form which uses several Wizardsteps. I also have a free text search on the same page. What I would like to do is be able to set the next button within the Wizard to the DefaultButton so that my users can select the Return key to process the form. At the moment the Search button takes precedence which is right for the majority of pages within the site.

Is this possible?

Many thanks

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old June 26th, 2006, 03:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Rit,

Take a look here: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=374

This explains how to set the default button in a master page.

For your user control, you'll need to use an extra trick: use FindControl on the appropriate part of the wizard, find its Id and then use its UniqueID property to set the default button.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old July 19th, 2006, 12:57 PM
BTC BTC is offline
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am also having this problem... Imar, I have read your excellent article and it was quite helpful. Thank you. I have tried the following in my Page_Load event handler:

        Master.Page.Form.DefaultButton = Wizard1.ActiveStep.FindControl("StartNavigationTem plateContainerID").FindControl("StartNextButton"). UniqueID;

This works for the first step in the wizard but does not for subsequent steps. I have also tried the following with the same results:

        Master.Page.Form.DefaultButton = Wizard1.FindControl("StartNavigationTemplateContai nerID").FindControl("StartNextButton").UniqueID;

Any help would be greatly appreciated. Rit, any luck?

Thanks, BTC

 
Old July 21st, 2006, 04:41 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think the button is called differently in subsequent steps. In the second step of a 4 step wizard, the button is called StartNextButton.

The easiesy way to find out the name is to create a clean, empty wizard with the required number of steps. Run the page and look at the HTML. You'll see the Next button is called StartNextButton. Click Next and look at the HTML again. Now the button is called StartNextButton.

Follow this pattern until you found all the different names for the buttons, and use that name to set the DefaultFocus.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: You Are Fading by Editors (Track 2 from the album: Cuttings) What's This?
 
Old August 8th, 2006, 10:14 AM
BTC BTC is offline
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar! You are correct, the Next button has different id's depending on which step you are on... I used the following code in my Page_PreRender method to set the default button:

if (Wizard1.ActiveStep.ID == "FirstStep")
   Master.Page.Form.DefaultButton = "StartNextButton";
else
   if (Wizard1.ActiveStep.ID == "LastStep")
        Master.Page.Form.DefaultButton = "FinishButton";
        else
            Master.Page.Form.DefaultButton = "StepNextButton";

(The button id's have been reduced... I looked at the source for each step to obtain the actual UniqueID)

Thanks again for your help! Your the man!

 
Old August 8th, 2006, 02:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great. Glad it worked out....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
wizard control MunishBhatia ASP.NET 2.0 Basics 0 April 15th, 2008 12:35 AM
wizard control Bill Crawley ASP.NET 2.0 Professional 0 July 12th, 2007 09:55 AM
Navigation Wizard Control everest ASP.NET 2.0 Professional 0 January 17th, 2007 06:22 PM
Wizard Control Issue mahajanvit ASP.NET 2.0 Basics 0 September 15th, 2006 12:57 AM
Calendar Control in a wizard frosty ASP.NET 2.0 Basics 5 July 28th, 2006 12:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.