Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Auto Select Text in Textbox

 
Logged in as: Guest
arrSession:exec spGetSession 2,4,46423
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP.NET >> Auto Select Text in Textbox
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Auto Select Text in Textbox - 4/27/2007 12:19:02 AM   
  sperkins

 

Posts: 1
Score: 0
Joined: 4/27/2007
Status: offline
I am new to ASP.Net, building a web page using VB.Net as the code behind file.   I need be able to have a text box select all text in box when it gets focus.  Trying to modify the code for Set Focus for this purpose without success.  Any suggestions.  Thanks.  Shawn

Set Focus (Works Great)


Private
Sub SetFocus(ByVal FocusControl As Control)
Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
With Script
.Append("<script language='javascript'>")
.Append("document.getElementById('")
.Append(ClientID)
.Append("').focus();")
.Append("</script>")
End With

RegisterStartupScript("setFocus", Script.ToString())
End Sub
 
Select All (1) Not working:
 

Private
Sub SelectAll1(ByVal FocusControl As Control) 'not working

'Sub provide SetFocus functionality....go over with Bill

Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
With Script
.Append("<script language='javascript'>")
.Append("document.getElementById('")
.Append(ClientID)
.Append("').select();")
.Append("</script>")
End With

RegisterStartupScript("SelectAll1", Script.ToString())
End Sub
 
Select All (2) Not working:


Private
Sub SelectAll(ByVal ctrl As Control) 'trying different ways to make this work

Dim selectScript As String = "<script language='javascript'>" & _
"document.getElementById('" + ctrl.ClientID & _
"').select();</script>"
RegisterStartupScript("SelectScript", selectScript)
End Sub
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP.NET >> Auto Select Text in Textbox Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts