Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Select all" on a TextBox

Status
Not open for further replies.

lelo66

Programmer
Sep 14, 2004
10
0
0
CH
Hi

On a webpage I fill some text from a database in a textbox.
Now I should "select all" the text in that textbox by code; like the user can do this using the context menu.

This site is written in VB.NET and I got the hint doing this clientside by javascript:
javascript:this.form.text_area.focus();this.form.text_area.select();

I tried this in the VB-Code:
'TextBox1.Attributes.Add("onLoad", "this.form.TextBox1.select();")

also in the aspx-Source:
<asp:textbox id="TextBox1" runat="server" Width="120px" OnLoad="javascript:select();"></asp:textbox>

Both do not work.

I'm new in javascript.

Anyone knows how to do this?

Thanks
Lelo
 
I tried the same with focus().

<asp:textbox id="TextBox1" runat="server" Width="120px" onLoad="javascript:this.form.text_area.focus();this.form.text_area.select();"></asp:textbox>

But i'm not sure if i can insert javascript in a aspx site.


Error 1 'javascript' is not a member of 'ASP.Site_aspx'.

Error 2 Name 'this' is not declared.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top