• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1187
  • Last Modified:

ASP.NET: How to detect lost focus in user control

Is there a way to detect lost focus of a user control? I have 5 user controls in an AJAX Tab Container. One for each tab panel. I want to save the data of each panel as soon as it looses focus. My workaround so far is to catch the ActiveTabChange event and the Click events of the buttons that are on each panel for extra navigation forward and backwars in the tabs. I would like to catch the loosing of the focus on each user control, e.g. if another programm is selected, or a click on any other element on the parent page is done. So in general who can i detect when a user control loses focus?

Marcus
0
MarcusKoch
Asked:
MarcusKoch
  • 2
1 Solution
 
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
As far as I know, apart from using the client-side event "onblur" there is no other way to detect a focus lost while the page is on the client side. You can add the onblur using the
ControlID.Attributes.Add("onblur", "someJavaScriptFunctionWhichMayDoSomethingUsingAjax();").
However, you should have caution that a certain logic will never allow your user to leave the control if there is some kind of validation applied on the data input, so code carefully to cope such situations too.
0
 
MarcusKochAuthor Commented:
I will try this tomorrow and get back with the results.

Marcus
0
 
MarcusKochAuthor Commented:
I finally changed the user interface.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now