How to return to previous section without losing data
-
I have a unique situation where all asp.net markup code are all one page divided by sections. In one particular section called
sect_MPE
, all markups are stored in this section. Users would enter data into textbox and DropDownList controls nd click the Preview button. If user has a has a need to go back to the previous section to make changes, the user is allowed to do so by click the Go Back button. Below is the method I have created for going back to the previous section.
Private Sub returnwithvalues() sect\_MPE.Show() 'Create and assign session variables 'Save txtDateReceived into a session variable for later use. Do this for rest of form fields Session("dtReceived") = txtDateReceived.Text If Session("dtReceived") IsNot Nothing Then Dim dteReceived As String = Session("dtReceived").ToString() txtDateReceived.Text = dteReceived End If Session("Iaddress") = instAddress.Text If Session("Iaddress") IsNot Nothing Then Dim ia As String = Session("Iaddress").ToString() instAddress.Text = ia End If End Sub Protected Sub goBack\_Click(ByVal sender As Object, ByVal e As EventArgs) Handles goBack.Click returnwithvalues() End Sub
When a user clicks the Go Back button, s/he is taken to the correct section, Sect_MPE section but values on the form are lost. Could please help with what's wrong with the code I posted above. In the sample code I posted above for instance, initially, the value of the form fields are stored in session. Then when user clicks to go go back, the values in session is stored back into the form field so the data persists. I might be approaching it incorrectly. Thanks in advance for your assistance.