Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Focus at end of text in textbox

Tags:

asp.net

Hey, Is it possible with easy options in ASP.NET to set the focus at end of text in a textbox-element ? Without JavaScript ?

like image 773
Patrik Avatar asked Nov 30 '25 17:11

Patrik


1 Answers

ASP.NET textboxes render as standard HTML inputs (with type="text") and the only way to achieve what you are asking is through javascript:

var textbox = document.getElementById('foo');
textbox.focus();
textbox.value = textbox.value;

where foo is the id of the generated input:

<input type="text" id="foo" name="foo" value="some text" />
like image 166
Darin Dimitrov Avatar answered Dec 03 '25 09:12

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!