Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have already described the situation above here I was trying to maintain the Form data of search page on click of Back button from search result page, details page and other pages. To maintain this I used the Class <code>SearchCriteria</code>. Below is the sample code for Class </p> <pre><code>public class SearchCriteria { private string _strName; private string _strCode; public string strName { set { _strName = value; } get { return _strName; } } public string strCode { set { _strCode = value; } get { return _strCode; } } } </code></pre> <p>I have assigned all Search Criteria to this class and kept that in Session so that I can access this anywhere.</p> <pre><code>SearchCriteria objSearch = new SearchCriteria(); objSearch.strName = txtFirstName.Text; objSearch.strCode = txtCode.Text ; if (Session["SearchCriteria"] != null) { Session.Remove("SearchCriteria"); Session["SearchCriteria"] = objSearch; } else { Session["SearchCriteria"] = objSearch; } </code></pre> <p>One Click of <code>Back</code> button from search result, details and other pages I am redirecting to Search Page with the <code>QueryString</code> PostBack=1</p> <pre><code>protected void btnBack_Click(object sender, EventArgs e) { Response.Redirect("Default.aspx?PostBack=1", false); } </code></pre> <p>And on the <code>Page_Load</code> of Search page I checked for the 'QueryString' PostBack and based on the QueryString, I have assigned the Search Criteria to the Controls from Session.</p> <pre><code>if (Request.QueryString["PostBack"] != null) { SearchCriteria objSearch = new SearchCriteria(); if (Session["SearchCriteria"] != null) { objSearch = (SearchCriteria)Session["SearchCriteria"]; txtFirstName.Text = objSearch.strName; txtCode.Text = objSearch.strCode; } } </code></pre> <p>I don't know what is recommended for different situations but like to know. Please share your ideas.</p> <p>Many Thanks to Ashish Bahu, his answer helped me a lot on this.</p> <p>I was looking for any other good way to do this without using Session or Viewstate but didn't found anything and finally end up with the above solution, If someone is having any other good solution for this please share. Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload