Auto Select Text in Textbox

Author Message
sperkins

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 4/27/2007
  • Status: offline
Auto Select Text in Textbox Friday, April 27, 2007 1:19 AM (permalink)
0
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
 
#1
    ganesh1975

    • Total Posts : 2
    • Scores: 0
    • Reward points : 0
    • Joined: 8/26/2008
    • Status: offline
    RE: Auto Select Text in Textbox Tuesday, August 26, 2008 9:57 PM (permalink)
    0
    other way, if u use ajax in form

    scriptmanager1.setfocus(control ID)
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • 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
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9