asp.net retention status between multiple pages

Source: Internet
Author: User
Preface


today is my new job the next day, finally returned to CSDN, on their blog to write the first article.


do not remember how many blogs they have, today began to decide, in this record, I later days and life bar.


asp.net retention status between multiple pages


only remember that the status in the ASP.net page is saved by viewstate. I think the page can also borrow viewstate.


Microsoft said, ViewState is only relative to the single page, and, I also found that there are a lot of work can be reversed edit


the ViewState within the page. Because it's encoded in Base64. Of course, you can also encrypt it. Since, it does not meet the multiple page

Keep the state problem between
, then don't use it.


with the session is not able to solve it:


I have a simple try, because the page control is not too much, just 10, I listed their session value. And then in

Initializes its state in the
Page_Load. As follows: This will do.


private void Page_Load (object sender, System.EventArgs e)


{





if (! IsPostBack)


{


//


if (session["Deal_page"]!=null)


{//This is
from other pages.

if (session["Deal_page"). Equals ("Deal_page"))


{


Init_form ();


}


}





Bind_draggrid ();


}


}


private void Init_form ()


{





Txtcompanyname.text = session["Secomp"]. ToString ();


Txtrsrvman.text = session["Sersrv"]. ToString ();


Txtphone.text = session["Sephon"]. ToString ();


Txtsalemanger.text = session["Sesale"]. ToString ();


Txtcronum.text = session["Secron"]. ToString ();


Txtgrpgstname.text = session["SEGRPG"]. ToString ();


Txtsdate.text = session["Sesdate"]. ToString ();


Txtedate.text = session["Seedate"]. ToString ();


Txtdptsdate.text = session["Sedpts"]. ToString ();


Txtdptedate.text = session["Sedpte"]. ToString ();





}


may have a better way, but I haven't thought too well. Let's use this for a while.





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.