Pressing back prefills inputs with value from right before submit

扶醉桌前 提交于 2019-12-01 11:19:57

An alternative is clearing out the fields with JavaScript when then document is done loading.

You could perhaps introduce a 'dummy' URL variable in order to trick the browser into believing it is a completely new page.

www.example.com/form.aspx?dummy=3423902

Use some javascript to make the browser pull the page again with a new random dummy=

The sever just igores this value.

I understand this will cause 2 postbacks each time but should certainly work. Work on 'asking' the browser to not cache first using the http headers - although I believe when you say:

I would prefer to not disable asp.net cache but wouldn't mind if there is no alternative. All the google hits for disabling cache didn't work though.

That this isn't working.

This should work. It's a jquery function so you would need to have that referenced in your page. As an example, this will set the value of the input item to "A"...


$(document).ready(function() {
    // this code will be run immediately after the page has displayed.
    // "ROpt" is the id of the field.
    $("#ROpt").val("A");
 });
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!