asp:Wizard control - hiding "next" button on certain steps.

N

Nick Gilbert

Hi,

I'm using the asp:Wizard control and on some of the steps, I would only
like the user to be able to progess to the next step by clicking an
image button. Therefore I would like to be able to hide the Next button
on these steps.

Is there any way to do this?

I know you can convert the navigation to a template, but this is a
common template for all steps rather than a template for a particular step.

Thanks,

Nick...
 
W

Walter Wang [MSFT]

Hi Nick,

You can use following steps to hide or show each step's next/prev button:

1) Add following CSS rules to your ASPX:

<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.hidden { display: none; }
.visible { display: inline; }
</style>
</head>


You can find more information about CSS display here:

#CSS2 - The display declaration
http://www.quirksmode.org/css/display.html




2) Handle the Wizard's ActiveStepChanged event:

protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
{
if (Wizard1.ActiveStepIndex == 1)
{
Wizard1.StepNextButtonStyle.CssClass = "hidden";
}
else
{
Wizard1.StepPreviousButtonStyle.CssClass = "visible";
Wizard1.StepNextButtonStyle.CssClass = "visible";
}
}


Hope this helps.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

Nick Gilbert

Thanks Walter. I hadn't thought of doing that. It's a shame you can't
have per-step templates because this solution seems a bit of a hack to
me. It would be nicer if you could set which buttons appear in each step
in the step declaration or a template inside the step.

I have since had another idea which I might use:
I can simply hide the buttons completely by using an empty template then
add back in the buttons I need manually in the WizardStep template. I
can then change the active step in the onclick handler for those buttons.

Thanks,

Nick...
 
N

Nick Gilbert

Actually, this turns out to be much easier than I thought.

If you want to customise when the next and previous buttons appear you
just need to do the following:

1. In design view, select "convert to StepNavigationTemplate" on the Wizard.
2. Copy the next and previous buttons into the templates for the steps
that require them. (the only important thing is that the CommandName is
either MoveNext or MovePrevious.

3. Delete the contents of the StepNavigationTemplate to avoid duplicate
buttons:

<StepNavigationTemplate></StepNavigationTemplate>

Done! The buttons work automatically with no additional code as the
Wizard control just seems to check the CommandName on postback.

This means you can use LinkButtons or ImageButtons too in the same way
as long as the commandname is the same.

Nick...
 
W

Walter Wang [MSFT]

Hi Nick,

Thank you for sharing your solution. You're right that it's the CommandName
of a control that supports bubbling event controls Next or Previous step.
By removing the default StepNavigationTemplate content and using
CommandName, you have full control of how to show the navigation controls.


For more information about event bubbling:

#Bubbling an Event
http://msdn2.microsoft.com/en-gb/library/aa719644(VS.71).aspx

#Control.RaiseBubbleEvent Method (System.Web.UI)
http://msdn2.microsoft.com/en-us/library/system.web.ui.control.raisebubbleev
ent.aspx

#Event Bubbling Control Sample
http://msdn2.microsoft.com/en-gb/library/aa720044(VS.71).aspx


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

arun

Hi

Please give some working code on how to access the next and previous
buttons. In which event I will write the code

Thanks

Arun
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top