|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Wizard ControlI have a page with a wizard control. Note, this page does have a masterpage. The wizard control has 5 steps; all steps have AllowReturn set to true. Step 1 allows the user to browse, select and upload a spreadsheet. This step also has a radiobuttonlist with values set to Fixed or Custom. In the NextButtonClick script, if the value of the radiobuttonlist is fixed then the wizard proceeds to step 2 otherwise to step 3 (Wizard1.ActiveStepIndex = 2) Step2 has a formview with several textboxes . On the Formview, I have a PreRender event set-up where I set-up default values to be displayed for these textboxes. The user can update the values in these textboxes as required then click next to go to Step 3. 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? I tried the following but am having a problem. I set-up 2 textbox fields on the page outside the wizard to contain the value of the previous and next step index (textbox 3 is for the previous step and textbox 4 is for the next step index as follows: protected void OnActiveStepChanged_SaveCurrPrevIndex(object sender, EventArgs e) { if (IsPostBack) //NOT first time { TextBox3.Text = TextBox4.Text; TextBox4.Text = Wizard1.ActiveStepIndex.ToString(); } } In the formview prerender script I try to check the value of these text boxes. If the previous step is greater than the current step then I don't want to display the default values. protected void FV1_PreRender(object sender, EventArgs e) { TextBox tb3 = this.FindControl("TextBox3") as TextBox; TextBox tb4 = this.FindControl("TextBox4") as TextBox; int inttb3 = Convert.ToInt32(this.FindControl("TextBox3.Text")); int inttb4 = Convert.ToInt32(this.FindControl("TextBox4.Text")); if (inttb3 >= inttb4) { FormView FV1 = (FormView)sender; TextBox tb1 = FV1.FindControl("TextBox1") as TextBox; tb1.Text = "0"; TextBox tb2 = FV1.FindControl("TextBox2") as TextBox; tb2.Text = "0123"; } } In the code above, I cannot get the values set-in textbox3 and textbox4. I would like to know how to: 1) Show the default values only the first time the formview is displayed and then show the values as they are if changed by the user; 2) How to access the textbox3 and textbox4 values in this prerender section. Thanks as always for your help. -- Morris Hi Morris,
>Step 3 provides 2 buttons allowing the user additional capabilities. If If my understanding is correct, the following code can demonstrate your >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? 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 all***@microsoft.com. 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: msd***@microsoft.com. ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/subscriptions/aa948874.aspx ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Thanks Allen. That worked.
A quick question, is "thefirsttime" a variable or a custom name to .net? I tried to read-up on ViewState but info was hard to understand. Can you send me a beginer's tutorial on viewstate? -- Show quoteHide quoteThanks Morris "Allen Chen [MSFT]" wrote: > 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 > all***@microsoft.com. 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: > msd***@microsoft.com. > > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/subscriptions/aa948874.aspx > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Hi Morris,
You can replace "thefirsttime" with anything you like. You can refer to the following article to learn more details about ViewState. http://msdn.microsoft.com/en-us/library/ms972976.aspx Regards, Allen Chen Microsoft Online Support Thanks.
I am wondering if you can check out my other issue in post Wizard Control - Issue 2 and see if there is something you can recomend. As always, I appreciate your feedback and help. -- Show quoteHide quoteThanks Morris "Allen Chen [MSFT]" wrote: > Hi Morris, > > You can replace "thefirsttime" with anything you like. You can refer to the > following article to learn more details about ViewState. > > http://msdn.microsoft.com/en-us/library/ms972976.aspx > > > Regards, > Allen Chen > Microsoft Online Support > > Hi Morris,
>I am wondering if you can check out my other issue in post Wizard Control Thomas Sun is willing to assist on this issue. I've forwarded this thread - >Issue 2 and see if there is something you can recomend.? to him to let him know more about your scenario. You can follow up in the original thread. Thank you for using our Newsgroup Support Service. 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: msd***@microsoft.com. Thanks Allen. Got the answer from Thomas Sun.
-- Show quoteHide quoteThanks Morris "Allen Chen [MSFT]" wrote: > Hi Morris, > > >I am wondering if you can check out my other issue in post Wizard Control > - > >Issue 2 and see if there is something you can recomend.? > > Thomas Sun is willing to assist on this issue. I've forwarded this thread > to him to let him know more about your scenario. You can follow up in the > original thread. > > Thank you for using our Newsgroup Support Service. > > 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: > msd***@microsoft.com. > >
Best practice ASP SQL
Specifying property defaults how to pass the current user with reportviewer control viewing xml ASP.NET equivelant for include files that won't cause problems Control is not showing inherited properties in property grid Programmatically add textbox control with incrementing id Is here a web control to create tasks/calendars in Outlook ? Treeview Databinding Filling the text of Buttons over a public class |
|||||||||||||||||||||||