ASP.NET Wizard Control Serious Bugs in Navigation

No.of Views1992
Bookmarked0 times
Downloads 
Votes0
By  MSD   On  09 Jul 2010 09:07:10
Tag : ASP.NET , Web Controls
Wizard seems to get confused between its navigation controls in its different steps
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

The Problem

Wizard seems to get confused between its navigation controls in its different steps

Expected Behavior

The confirm Message is supposed to appear only when the Next Button of the third step is clicked.

Actual Behavior

 After click Next and Previous a couple of times, Next Button of other steps now display the confirmation message.

HTML

<asp:Wizard ID="wz1" runat="server" DisplaySideBar="False" ><WizardSteps><asp:TemplatedWizardStep ID="step1" runat="server" Title="Step 1" StepType="start"><ContentTemplate>Step1 Content</ContentTemplate><CustomNavigationTemplate><asp:Button ID="btnNext1" runat="server" UseSubmitBehavior="true" CommandName="MoveNext"
Text="Next1" /></CustomNavigationTemplate></asp:TemplatedWizardStep><asp:TemplatedWizardStep ID="step2" runat="server" Title="Step 2" StepType="Step"><ContentTemplate>Step2 Content</ContentTemplate><CustomNavigationTemplate><asp:Button ID="btnPrevious2" runat="server" CausesValidation="false"
CommandName="MovePrevious" Text="Previous2" /><asp:Button ID="btnNext2" runat="server" UseSubmitBehavior="true" CommandName="MoveNext"
Text="Next2" /></CustomNavigationTemplate></asp:TemplatedWizardStep><asp:TemplatedWizardStep ID="step3" runat="server" Title="Step 3" StepType="Step"><ContentTemplate>Step3 Content</ContentTemplate><CustomNavigationTemplate><asp:Button ID="btnPrevious3" runat="server" CausesValidation="false" UseSubmitBehavior="false"
CommandName="MovePrevious" Text="Previous3" /><asp:Button ID="btnNext3" runat="server" UseSubmitBehavior="true" CommandName="MoveNext"
Text="Next3" /></CustomNavigationTemplate></asp:TemplatedWizardStep><asp:TemplatedWizardStep ID="step4" runat="server" Title="Step 4" StepType="Step"><ContentTemplate>Step4 Content</ContentTemplate><CustomNavigationTemplate><asp:Button ID="btnPrevious4" runat="server" CausesValidation="false" UseSubmitBehavior="false"
CommandName="MovePrevious" Text="Previous4" /><asp:Button ID="btnNext4" runat="server" UseSubmitBehavior="true" CommandName="MoveNext"
Text="Next4" /></CustomNavigationTemplate></asp:TemplatedWizardStep></WizardSteps></asp:Wizard>

Code (Behind)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) ViewState["called"] = false;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

Button btnNext;
btnNext =
step3.CustomNavigationTemplateContainer.FindControl("btnNext3") as Button;
btnNext.Attributes.Add("onclick", "return confirm('" + DateTime.Now.ToString() + "');");
ViewState["called"] = true;

}

}

Note that till now I have not found a certain pattern to this problem, each case is different, for example, adding a button would change when the bug would appear. In this example clicking Next acouple of times will show the unexpected behavior.


I don't know what causes this, for now I am gonna let go the use of the Wizard control and create my own solution (showing and hiding panels).Thank you for reading.

 
Sign Up to vote for this article
 
About Author
 
MSD
Occupation-Software Engineer
Company-
Member Type-Fresh
Location-Lebanon
Joined date-31 Jan 2010
Home Page-
Blog Page-http://msd-bml.blogspot.com
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top