1

Is there any way to find out which asp.net component has focus by using a server or client script?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Jambobond
  • 619
  • 3
  • 12
  • 23

3 Answers3

2

Definitely not using a server script. It's very important to understand that your server code does not run on an "active" page. ASP.Net Server code only prepares html to send to the browser before the user sees it — even on a post back it's recreating the entire html page from scratch.

Client javascript is another story: you can handle the onfocus event for any element you care about.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
0

How do I find out which Javascript element has focus?

If the requirement is for IE only you can use

document.activeElement
Community
  • 1
  • 1
rahul
  • 184,426
  • 49
  • 232
  • 263
0

How to determine which html page element has focus?

Community
  • 1
  • 1
Mr. Smith
  • 5,489
  • 11
  • 44
  • 60