user3224577
user3224577

Reputation: 35

Focus eventhandler for Textbox and dropdownlist using asp.net web application

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

Answers (2)

Harshit
Harshit

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

Bhavesh Kachhadiya
Bhavesh Kachhadiya

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

Related Questions