Bran-Damage
asked on
Set focus to a text box on a web page after textchanged event...
I have an aspx page that has text boxes. On one of my text boxes I have a changedText event.
After the changed text event the cursur goes to an undesirable location.
I tried to do a me.txtph.focus() but that did not work.
What I am looking to do is either go to me.txtph or put the cursur when they hit tab to the next tab order or when they click on a different field, keep the cursur there.
Any ideas would be helpful.
I have attached my changed text event code.
After the changed text event the cursur goes to an undesirable location.
I tried to do a me.txtph.focus() but that did not work.
What I am looking to do is either go to me.txtph or put the cursur when they hit tab to the next tab order or when they click on a different field, keep the cursur there.
Any ideas would be helpful.
I have attached my changed text event code.
Protected Sub txtstate_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Try
If Me.txtstate.Text = "AE" Or Me.txtstate.Text = "AA" Or Me.txtstate.Text = "AP" Then
If TxtdelDoc.Text <> "" And TxtFromCountry.Text <> "" And txtcountry.Text <> "" Then
btnInternational.Enabled = True
End If
Else
btnInternational.Enabled = False
End If
Me.txtph.Focus()
Catch ex As Exception
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both of these solutions work, but my main issue, I found out, was not actually with the java script. There was an auto postback occurring that was causing the set focus to go to another area than desired.
I modified this, used your java script... BOOM, worked like a charm
I modified this, used your java script... BOOM, worked like a charm
use Page.SetFocus method with control's ID as a parameter