sde Posted November 18, 2003 Posted November 18, 2003 i have 2 text boxes in a form. areacode and phone i want to make it so when 3 digits are entered in the area code, it sets the focus to the phone field. is there a method to setfocus in asp.net? or do i have to write some javascript? Quote codenewbie
Moderators Robby Posted November 18, 2003 Moderators Posted November 18, 2003 For something like that it would have to be JScript. Quote Visit...Bassic Software
fadi Posted November 19, 2003 Posted November 19, 2003 here is a piece of code to set the focus from asp.net. but this code wont help you in this case since u will need to go to the server. thats why u should use the focus() javascript method. The code im providing actually writes javascript to the client from the server. Anyways here is the code: method call: setFocus(TextBox1.ClientID) method declaration: Private Sub setFocus(ByVal ctrlClientID As String) RegisterStartupScript("focus", "<script language=""JavaScript"">" & vbCrLf & _ vbTab & "Form1." & ctrlClientID & ".focus();" & _ vbCrLf & vbTab & "Form1." & ctrlClientID & ".select();" & vbCrLf & "<" & "/script>") End Sub Quote
Muhad Posted November 20, 2003 Posted November 20, 2003 I needed that real bad. Thanks for posting the code! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.