|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with ASP.NET wizard hiding / removing stepsWhen using the ASP.NET 2.0 Wizard control, I would like to hide Step 2 when the TextBox in Step 1 has a value of 1. The code below allows me to do that, but after removing Step 2, TextBox values in later steps no longer persist. (EnableViewState has no effect.) Can anyone enlighten me where my code is going wrong. Thanks in advance. Tien Leok I have the following code in my aspx page: <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" OnLoad="Wizard1_Load"> <WizardSteps> <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3"> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> </asp:WizardStep> </WizardSteps> </asp:Wizard> and the following code in my aspx.cs: protected void Wizard1_Load(object sender, EventArgs e) { if (TextBox1.Text == "1") Wizard1.WizardSteps.Remove(WizardStep2); } Hi Tien,
The text value doesn't get retained as the page doesn't get posted back when you use previous button in Step3. To retain the text value of Step3 after traversing to other steps and returning to Step3, include the text value of TextBox3 in the ViewState. Coding: cs: private void Page_Load(object sender, System.EventArgs e) { if (ViewState["text3"] != null) { TextBox3.Text = ViewState["text3"].ToString(); } } protected void Wizard1_Load(object sender, EventArgs e) { if (TextBox1.Text == "1") Wizard1.WizardSteps.Remove(WizardStep2); } protected void StoreValue(object sender, WizardNavigationEventArgs e) { if (TextBox3.Text != string.Empty) { ViewState["text3"] = TextBox3.Text; } } ASPX: <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" OnLoad="Wizard1_Load" OnPreviousButtonClick="StoreValue"> <WizardSteps> <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3"> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> </asp:WizardStep> </WizardSteps> </asp:Wizard> Let me know if you have any doubts. Regards, Valli (www.syncfusion.com) ASP.Net FAQ: http://www.syncfusion.com/faq/aspnet/default.aspx Complete set of ASP.Net controls and components http://www.syncfusion.com/toolsweb <tienl***@gmail.com> wrote in message Show quoteHide quote news:%23gMsZ89nGHA.4124@TK2MSFTNGP03.phx.gbl... > Hi, > > When using the ASP.NET 2.0 Wizard control, I would like to hide Step 2 > when the TextBox in Step 1 has a value of 1. The code below allows me to > do that, but after removing Step 2, TextBox values in later steps no > longer persist. (EnableViewState has no effect.) > > Can anyone enlighten me where my code is going wrong. > > Thanks in advance. > > Tien Leok > > > I have the following code in my aspx page: > > <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" > OnLoad="Wizard1_Load"> > <WizardSteps> > <asp:WizardStep ID="WizardStep1" runat="server" > Title="Step 1"> > <asp:TextBox ID="TextBox1" > runat="server"></asp:TextBox> > </asp:WizardStep> > <asp:WizardStep ID="WizardStep2" runat="server" > Title="Step 2"> > <asp:TextBox ID="TextBox2" > runat="server"></asp:TextBox> > </asp:WizardStep> > <asp:WizardStep ID="WizardStep3" runat="server" > Title="Step 3"> > <asp:TextBox ID="TextBox3" > runat="server"></asp:TextBox> > </asp:WizardStep> > </WizardSteps> > </asp:Wizard> > > and the following code in my aspx.cs: > > protected void Wizard1_Load(object sender, EventArgs e) > { > if (TextBox1.Text == "1") > Wizard1.WizardSteps.Remove(WizardStep2); > }
Treeview SelectedNodeStyle Problem
Wizard control in 2.0 and dynamic items Passing values to user controls - naughty problem Why it doesn't work? web controls install problem with hidden field from a custom control in a form Can't access webpage's controls from the code-behind file after putting it in a <asp:LoginView/> Problem with spaces in values of the DataTextField property of datagrid control Interrogating cells on current row for GridView CheckBoxList Control column width |
|||||||||||||||||||||||