将焦点设置在文本框中的文本末尾

Pat*_*rik 2 asp.net

嘿,ASP.NET中的简单选项是否有可能将焦点设置在textbox-element中的文本末尾?没有JavaScript?

Dar*_*rov 5

ASP.NET文本框呈现为标准HTML输入(使用type ="text"),实现所要求的唯一方法是通过javascript:

var textbox = document.getElementById('foo');
textbox.focus();
textbox.value = textbox.value;
Run Code Online (Sandbox Code Playgroud)

其中foo是生成的输入的id:

<input type="text" id="foo" name="foo" value="some text" />
Run Code Online (Sandbox Code Playgroud)