[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1168
  • 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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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