开发者

How do i make form data not disappear after hitting refresh?

I went to test my page on another browser. On google chrome i can fill out a form, hit back and forward and still have the data there. Now i need to refresh the page so certain data is correct (such as sessi开发者_StackOverflowon id if the cookie expires or user logs out before submitting). I refresh and lose all data. Is there some option i can set so all data is kept?


What framework are you using? For example, ASP.Net WebForms would handle this via ViewState (yuck), ASP.Net MVC would require you to do this manually etc.

You essentially need to persist your data somewhere while the page reloads, and then re-populate the controls.


You would have to send the values to the server while they are typed in, and then repopulate the form fields on refresh.


Yes, the only secure way to do this is to use a serverside script to store the form temporarly. Since browsers handles back/forward diffrently your page won't be x-browser compatible if you don't use the server. If the user hits the back button you are kind of lost already since no post is done, unless you post the form with some javascript magic before the new page is refreshed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜