Hali
Hali

Reputation: 591

Page state is lost while refreshing the page

In my webpage, there is a repeater control which holds an image and its description. After the page is been loaded, the user can reorder the images(Jquery is used for reordering divs). After the reordering, if the user refresh the page or click any button, the page will go back to the previous state before reordering. How can I prevent this.

The repeater control is in .aspx page.

Thank you in advance.

Upvotes: 0

Views: 224

Answers (1)

Giorgio Minardi
Giorgio Minardi

Reputation: 2775

If the page is refreshed there's nothing really you can do. The browser will send the same request you sent before.
Because the sorting is done client side, you should save it states somewhere and then you can request again the page to the server. So for instance, let say that you order your repeater by the "CreatedDate" column. Once ordered, you can save the column name of the ordering in a hidden field. Once you click a button, the page is loaded again and you step in the page load event in the code behind. At that point you can get the value of the hiddenfield posted, you will find that it got "CreatedDate" as a value. You can then return the datasource for your repeater already ordered by date and the user will have the same view he had before posting the page.

Upvotes: 1

Related Questions