i have an auto refreshed page with one text input. If i write text on that text input and when the page refreshed, the text still there and the cursor still the end of that text. but if i add autocomplete = off
in textbox style it won't work. i test this using mozilla 31.
But when i test open using chrome 36, the text i write before is disappeared after the page refreshed (with or without autocomplete = off)
here is my code
<script type="text/javascript">
$(function () {
var SearchInput = $('#text');
var strLength = SearchInput.val().length;
SearchInput.focus();
SearchInput[0].setSelectionRange(strLength, strLength);
});
@Html.TextBox("text", null, new { style = "width: 800px"})
This is default behavior by the browser from my experience only with FireFox.
If you want to make sure the data is always in the textbox on refresh, then you will need to do something like create a javascript cookie with the textbox data inside onChange of the textbox or so, and then append that cookie data inside the textbox in the page onLoad event. You can also add a querystring to the page upon refresh, or use HTML5 storage, if you do not want to write a cookie.