Last post Dec 30, 2009 01:03 AM by qwe123kids
Dec 30, 2009 12:23 AM|shtrudel|LINK
I have a webform that collect details from the user. When the user click the OK button, in order to save details, the page
perform a data validation on server side (vb-code). If there is something missing the user is redirected to a page that explain
him/her what is missing/wrong in the form and let him go back to the details collector form. Problem is when I go back to the
details webform all the controls are reset to their initial state and values. I would like to preserve the controls state/values while the
user sees the explanation page so when the user is back to the details collector webform they will get all the details they already
Dec 30, 2009 12:50 AM|chrisbarba|LINK
You can display the validation messages on the page (like in a validation summary).
You can put errors from server side validation routines in the summary also - best idea
Or display the errors in a new page you popup. - 2nd best
Or save the data input to a database and reload the page when the user comes back (maybe use query string parameter for the recordID) - most work
Dec 30, 2009 01:01 AM|ramesh866|LINK
you can use session for preserving the values...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If (Not Page.IsPostBack) Then
TextBox1.Text = CType(Session.Item("one"), String)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Session("one") = TextBox1.Text
but if you are validating something that is regular and which can be validated in client side itself, then you can use the validation controls that are built in, which preserves the values if there is ant error in data that is entered
Dec 30, 2009 01:01 AM|Yasser.net|LINK
As the asp is stateless protocol, it won't maintain the values in the form after postback.
You can store the control values in the view state as Viewstate["Text"] = control.text;
Later you can bind the viewstate to the controls.
Please read the article for further clarification
Dec 30, 2009 01:03 AM|qwe123kids|LINK
U may use Viewstate..