I know, there is a property for textbox control in windows form, called selectall()
.
I am trying to achieve the same in my web app, for a textbox, once it recieves the focus()
, i am trying to select all the text in the textbox.
I know I can write some jquery for this, but, is there any other easier way to achieve this?
Try this:
<asp:TextBox ID="Textbox1" runat="server" onFocus="this.select()" />
No, you cannot do this without some client side scripting code. The code is very simple, though. In your Page_Load
event, just specify:
myTextBox.Attributes.Add("onfocus", "this.select()")
Textbox1.Attributes["onFocus"] = "this.select()";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With