Hi Morris,
>Step 3 provides 2 buttons allowing the user additional capabilities. If
>during this step the user selects the Previous button to go to step 2, I
want
>the textbox fields to display the values changed by the user not the
default
>values. How do I do this?
If my understanding is correct, the following code can demonstrate your
scenario. For the simplicity I use TextBox to replace the FormView in your
case.
aspx:
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step
1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step
2">
<asp:TextBox ID="TextBox1" runat="server"
OnPreRender="TextBox1_PreRender"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server"
Title="Step 3">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
aspx.cs:
protected void TextBox1_PreRender(object sender, EventArgs e)
{
TextBox t = (TextBox)sender;
t.Text = "Default Value";
}
The problem is, if you go to step 2, change the value in the TextBox and
then go to step 3 and back to step 2. The value you changed is overwritten
because "Default Value" is reset in the PreRender event of TextBox.
The solution is, save a flag in ViewState, which can be preserved during
postbacks. We can use this flag to know if it's the first time to assign
value to TextBox.
The updated code:
protected void TextBox1_PreRender(object sender, EventArgs e)
{
if (ViewState["thefirsttime"] == null)
{
ViewState["thefirsttime"] = false;
TextBox t = (TextBox)sender;
t.Text = "Default Value";
}
}
Please test it and let me know if it works. If I misunderstood you please
send me a repro project. I'll test it on my side. My email is
. Please update here after sending the project in case
I missed that email.
Regards,
Allen Chen
Microsoft Online Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 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. 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/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.