Reputation: 35
Can anyone tell me a event for focus on textbox and dropdown.(ie) If a tab comes on textbox or dropdown using asp.net web application.I searched but i can find for leave focus such as textchanged or selectindexchange.Pls provide me any reference.
Upvotes: 0
Views: 521
Reputation: 1
You can try:
myTextBox.Focus();
But remember myTextBox.Focus()
tries to set focus on the textbox element.
If the element visibility is hidden, Focus()
will not work. So do make sure that your element is visible before calling Focus()
.
Upvotes: 0
Reputation: 3962
You can do things in following way:
Javascript code :
<script>
function myFunction(x)
{
alert('Get Focus');
//Do your stuff here.
}
</script>
HTML code:
Enter your name: <input type="text" onfocus="myFunction(this)">
Upvotes: 1