开发者

Keeping record of the state of the page in asp.net?

开发者 https://www.devze.com 2023-03-08 23:11 出处:网络
For example i am on page1.aspx, I have few drop downs and radio buttons on the page, and few text fields. I have have a button on page1.aspx that takes you to page2.aspx. And i have a back button on p

For example i am on page1.aspx, I have few drop downs and radio buttons on the page, and few text fields. I have have a button on page1.aspx that takes you to page2.aspx. And i have a back button on page2.aspx that takes you back to the page1.aspx. What is the best way to save the state of all drop downs and radio buttons etc of page1.aspx when moving to page2.aspx, and the reload the page1.aspx with those saved states when back button is clicked.

This may also include some objects that I want to save while i was on page1.aspx, and then carry on with it when i come back to page1.aspx

should i create individual classes for each page, and save their objects in session and then retrieve them back? is this a good approach?

should i use query strings to do this job?

or is their any other better way (a default industry practic开发者_JAVA技巧e)?


You could save the values in Session when redirecting from the page. Later on you could retrieve that value when you want.

Sesssion["myData"] = "Hello World";//to store in session
string str = (string)Session["myData"];//retreieving from sesssion.

Using session would be fine if it wouldn't increase the memory pressure to a great extent.


Not sure your Page2.aspx is for?, if you want to just show some information on it from Page1.aspx..try Server.Transfer, or I will prefer you go with Abdul Muqtadir answer

0

精彩评论

暂无评论...
验证码 换一张
取 消