Wizard Next Button

M

Morris Neuman

Hi,

Is there an easy way to not show the Next button on certain steps of the
wizard?
 
T

Thomas Sun [MSFT]

Hi Morris,

Based on my understanding, you want to hide default Next Button in Wizard
control's step. If I have misunderstood you, please feel free to let me
know.

There are a couple of ways to set Next Button's Visible. One is using
Wizard control's templates; another is programmatically locate the button
and set its property.

##Using Wizard control's templates:
Wizard control contains templates that allow you to customize the look and
feel. We can convert the steps to StartNavigationTemplate,
StepNavigationTemplate, FinishNavigationTemplate, etc. If we do so, we can
set Next Button's Visible property in HTML markup.

For example, I want to hide the Next Button in first step.
1. Drag and drop a Wizard control to page
2. Right click this Wizard control and select "Convert to
StartNavigationTemplate"
3. Enter this page's markup Source view and set Visible property to false
of Button named "StartNextButton" in startnavigationtemplate.

##Set Next Button's property programmatically:
We can set Next Button's property at runtime. To do so, we need to get its
instance firstly.

The following example is set Next Button's property at runtime:
=============================
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void btnShow1_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StartNavigationTemplateContainerID$StartNextButton" is the UniqueID of
Next Button within startnavigationtemplate.
Button btn =
(Button)Wizard1.FindControl("StartNavigationTemplateContainerID$StartNextBut
ton");
btn.Visible = true;

}

protected void btnHideButton_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StepNavigationTemplateContainerID$StartNextButton" is the UniqueID of Next
Button within stepnavigationtemplate.
Button btn =
(Button)Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = false;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
<asp:button ID="btnShow1" runat="server"
OnClick="btnShow1_Click" Text="Show NextButton In Step1" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
<asp:button ID="btnHideButton" runat="server"
OnClick="btnHideButton_Click" Text="Hide Next Button" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 3">
</asp:wizardstep>
</wizardsteps>
<startnavigationtemplate>
<asp:button ID="StartNextButton" runat="server"
CommandName="MoveNext" Text="Next" Visible="false" />
</startnavigationtemplate>
<stepnavigationtemplate>
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</stepnavigationtemplate>
</asp:wizard>
</div>
</form>
</body>
</html>
==========================

For more information about Wizard Templates, see
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/standard/wizard.
aspx


I look forward to receiving your test results.



--
Best Regards,
Thomas Sun

Microsoft Online Partner Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================

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

--------------------
 
M

Morris Neuman

Thanks. I used the Wizard control template and was able to hide the Next
control.

Is there a way to make the Next button not show only on a specific step but
show on other steps?
--
Thanks
Morris


Thomas Sun said:
Hi Morris,

Based on my understanding, you want to hide default Next Button in Wizard
control's step. If I have misunderstood you, please feel free to let me
know.

There are a couple of ways to set Next Button's Visible. One is using
Wizard control's templates; another is programmatically locate the button
and set its property.

##Using Wizard control's templates:
Wizard control contains templates that allow you to customize the look and
feel. We can convert the steps to StartNavigationTemplate,
StepNavigationTemplate, FinishNavigationTemplate, etc. If we do so, we can
set Next Button's Visible property in HTML markup.

For example, I want to hide the Next Button in first step.
1. Drag and drop a Wizard control to page
2. Right click this Wizard control and select "Convert to
StartNavigationTemplate"
3. Enter this page's markup Source view and set Visible property to false
of Button named "StartNextButton" in startnavigationtemplate.

##Set Next Button's property programmatically:
We can set Next Button's property at runtime. To do so, we need to get its
instance firstly.

The following example is set Next Button's property at runtime:
=============================
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void btnShow1_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StartNavigationTemplateContainerID$StartNextButton" is the UniqueID of
Next Button within startnavigationtemplate.
Button btn =
(Button)Wizard1.FindControl("StartNavigationTemplateContainerID$StartNextBut
ton");
btn.Visible = true;

}

protected void btnHideButton_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StepNavigationTemplateContainerID$StartNextButton" is the UniqueID of Next
Button within stepnavigationtemplate.
Button btn =
(Button)Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = false;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
<asp:button ID="btnShow1" runat="server"
OnClick="btnShow1_Click" Text="Show NextButton In Step1" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
<asp:button ID="btnHideButton" runat="server"
OnClick="btnHideButton_Click" Text="Hide Next Button" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 3">
</asp:wizardstep>
</wizardsteps>
<startnavigationtemplate>
<asp:button ID="StartNextButton" runat="server"
CommandName="MoveNext" Text="Next" Visible="false" />
</startnavigationtemplate>
<stepnavigationtemplate>
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</stepnavigationtemplate>
</asp:wizard>
</div>
</form>
</body>
</html>
==========================

For more information about Wizard Templates, see
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/standard/wizard.
aspx


I look forward to receiving your test results.



--
Best Regards,
Thomas Sun

Microsoft Online Partner Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================

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

--------------------
 
T

Thomas Sun [MSFT]

Hi Morris,
Thanks. I used the Wizard control template and was able to hide the Next
control.

Is there a way to make the Next button not show only on a specific step but
show on other steps?

Thanks for your response.

As mentioned in my first post, we can set Next Button's Visible in Wizard
control's templates and programmatically locate the button.

## Set specific step's Next button Visible in Wizard's template

If we use Wizard control template and set Next button's Visible false, all
the Next buttons in this template will be hided. If we want to only hide
Next button on specified step, we can move Next button from template to
step's content.

For example, there is wizard control with four steps and we try to hide
Next button in step 3. The step 3 is stepnavigationtemplate so we just need
convert it to stepnavigationtemplate. The follow is the step:
1.Drag and drop a Wizard control to page
2.Right click this Wizard control and select "Convert to
StepNavigationTemplate"
3.Enter this page's markup Source view and copy stepnavigationtemplate's
contents to step2 and step3.
4.Set Next button's Visible false in step3.
5.Delete stepnavigationtemplate's contents.

Then, we will get something like following:
=============
<asp:wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
Step 1</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
Step 2<br />
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step3">
Step 3<br />
<asp:button ID="Button1" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="Button2" runat="server"
CommandName="MoveNext" Text="Next" Visible="False" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step4">
Step 4</asp:wizardstep>
</wizardsteps>
<stepnavigationtemplate>
</stepnavigationtemplate>
</asp:wizard>
================
Note: Please make sure the button's CommandName is right. Wizard control
uses the CommandName to handle Previous and Next button click event.

## Set specific step's Next button Visible property programmatically
We also can change Next button's Visible in Wizard's OnNextButtonClick or
OnSideBarButtonClick event for specified step.

For example, we try to hide step3's Next Button:
===============
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">


protected void Wizard2_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{
//Set step3 Next button's Visible false
if (e.NextStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = false;
}

}

protected void btnShow1_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StepNavigationTemplateContainerID$StartNextButton" is the UniqueID of Next
Button within stepnavigationtemplate.
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = true;
}

protected void Wizard2_PreviousButtonClick(object sender,
WizardNavigationEventArgs e)
{
if (e.CurrentStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = true;
}
}

protected void Wizard2_SideBarButtonClick(object sender,
WizardNavigationEventArgs e)
{
//Set step3 Next button's Visible false
if (e.NextStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButto
n");
btn.Visible = false;
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:wizard ID="Wizard2" runat="server" ActiveStepIndex="0"
OnNextButtonClick="Wizard2_NextButtonClick"
OnPreviousButtonClick="Wizard2_PreviousButtonClick"
OnSideBarButtonClick="Wizard2_SideBarButtonClick">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
Step 1</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
Step 2<br />

</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step3">
Step 3<br />
&nbsp;<asp:button ID="btnShow1" runat="server"
OnClick="btnShow1_Click" Text="Show NextButton In Step 3" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step4">
Step 4</asp:wizardstep>
</wizardsteps>
<stepnavigationtemplate>
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</stepnavigationtemplate>
</asp:wizard>
</div>
</form>
</body>
</html>
==============


I look forward to receiving your test results.
 
T

Thomas Sun [MSFT]

Hi Morris,

I wanted to see if the information provided was helpful. Please keep us
posted on your progress and let us know if you have any additional
questions or concerns.

I am looking forward to your response.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support



--------------------
X-Tomcat-ID: 38951825
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Thomas Sun [MSFT])
Organization: Microsoft
Date: Tue, 28 Apr 2009 06:41:22 GMT
Subject: RE: Wizard Next Button
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
Lines: 162
Path: TK2MSFTNGHUB02.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:4667
NNTP-Posting-Host: tk2tomimport1.phx.gbl 10.230.18.247

Hi Morris,
Thanks. I used the Wizard control template and was able to hide the Next
control.

Is there a way to make the Next button not show only on a specific step but
show on other steps?

Thanks for your response.

As mentioned in my first post, we can set Next Button's Visible in Wizard
control's templates and programmatically locate the button.

## Set specific step's Next button Visible in Wizard's template

If we use Wizard control template and set Next button's Visible false, all
the Next buttons in this template will be hided. If we want to only hide
Next button on specified step, we can move Next button from template to
step's content.

For example, there is wizard control with four steps and we try to hide
Next button in step 3. The step 3 is stepnavigationtemplate so we just need
convert it to stepnavigationtemplate. The follow is the step:
1.Drag and drop a Wizard control to page
2.Right click this Wizard control and select "Convert to
StepNavigationTemplate"
3.Enter this page's markup Source view and copy stepnavigationtemplate's
contents to step2 and step3.
4.Set Next button's Visible false in step3.
5.Delete stepnavigationtemplate's contents.

Then, we will get something like following:
=============
<asp:wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
Step 1</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
Step 2<br />
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step3">
Step 3<br />
<asp:button ID="Button1" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="Button2" runat="server"
CommandName="MoveNext" Text="Next" Visible="False" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step4">
Step 4</asp:wizardstep>
</wizardsteps>
<stepnavigationtemplate>
</stepnavigationtemplate>
</asp:wizard>
================
Note: Please make sure the button's CommandName is right. Wizard control
uses the CommandName to handle Previous and Next button click event.

## Set specific step's Next button Visible property programmatically
We also can change Next button's Visible in Wizard's OnNextButtonClick or
OnSideBarButtonClick event for specified step.

For example, we try to hide step3's Next Button:
===============
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">


protected void Wizard2_NextButtonClick(object sender,
WizardNavigationEventArgs e)
{
//Set step3 Next button's Visible false
if (e.NextStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButt o
n");
btn.Visible = false;
}

}

protected void btnShow1_Click(object sender, EventArgs e)
{
//Based on Wizard control's hierarchy,
"StepNavigationTemplateContainerID$StartNextButton" is the UniqueID of Next
Button within stepnavigationtemplate.
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButt o
n");
btn.Visible = true;
}

protected void Wizard2_PreviousButtonClick(object sender,
WizardNavigationEventArgs e)
{
if (e.CurrentStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButt o
n");
btn.Visible = true;
}
}

protected void Wizard2_SideBarButtonClick(object sender,
WizardNavigationEventArgs e)
{
//Set step3 Next button's Visible false
if (e.NextStepIndex == 2)
{
Button btn =
(Button)Wizard2.FindControl("StepNavigationTemplateContainerID$StepNextButt o
n");
btn.Visible = false;
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:wizard ID="Wizard2" runat="server" ActiveStepIndex="0"
OnNextButtonClick="Wizard2_NextButtonClick"
OnPreviousButtonClick="Wizard2_PreviousButtonClick"
OnSideBarButtonClick="Wizard2_SideBarButtonClick">
<wizardsteps>
<asp:wizardstep runat="server" Title="Step 1">
Step 1</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step 2">
Step 2<br />

</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step3">
Step 3<br />
&nbsp;<asp:button ID="btnShow1" runat="server"
OnClick="btnShow1_Click" Text="Show NextButton In Step 3" />
</asp:wizardstep>
<asp:wizardstep runat="server" Title="Step4">
Step 4</asp:wizardstep>
</wizardsteps>
<stepnavigationtemplate>
<asp:button ID="StepPreviousButton" runat="server"
CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:button ID="StepNextButton" runat="server"
CommandName="MoveNext" Text="Next" />
</stepnavigationtemplate>
</asp:wizard>
</div>
</form>
</body>
</html>
==============


I look forward to receiving your test results.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top