Set Focus To End Of Text In Textbox After Postback?
I've got a simple ASP.Net form with txtBox and btn. User click btn, which adds text to an ASP:TextBox in a postback (its adding a known 'starter text'. After the postback I'd like
Solution 1:
I found a solution in asp.net website ( check it for discussion about cross browser version of given solution!)
there is javascrip code that do it:
<scripttype="text/javascript">functionSetCursorToTextEnd(textControlID)
{
var text = document.getElementById(textControlID);
if (text != null && text.value.length > 0)
{
if (text.createTextRange)
{
varFieldRange = text.createTextRange();
FieldRange.moveStart('character', text.value.length);
FieldRange.collapse();
FieldRange.select();
}
}
}
</script>
Post a Comment for "Set Focus To End Of Text In Textbox After Postback?"