| |
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
|
|