473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

UserControl - Leave Event not being raised when press [ENTER] key

I have a usercontrol with code in the "leave" event which updates the final
data back into a database.

This works fine except if I have a default "accept" button on a form and
invoke it by pressing the ENTER key on the keyboard. In this case, it would
appear that whilst the code on the button is executing and therefore
presumably the button actually has focus, the leave event in the user
control is not fired.

Should I be interfacing with another event on the usercontrol instead of the
"leave" event.. or is there some other way round the problem?

Thanks in advance
Simon
Nov 21 '05 #1
2 5356
I'm considering using the LostFocus event. instead of leave.. It looks like
they both get fired? Though it would appear that possibly the Leave event
doesn't get fired in the scenario I describe whereas the LostFocus even
does??? (I've not tested this yet but I'm presuming that it should).

So, to guarantee that my data gets updated, where should I put my updating
code? LostFocus? Leave? or perhaps should I use Validated or Validating???
Do I need to do the update in multiple events (with the pain of running the
update code twice???)

Hope somebody can ease my confusion!!

Regards
Simon

"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a usercontrol with code in the "leave" event which updates the
final data back into a database.

This works fine except if I have a default "accept" button on a form and
invoke it by pressing the ENTER key on the keyboard. In this case, it
would appear that whilst the code on the button is executing and therefore
presumably the button actually has focus, the leave event in the user
control is not fired.

Should I be interfacing with another event on the usercontrol instead of
the "leave" event.. or is there some other way round the problem?

Thanks in advance
Simon

Nov 21 '05 #2
I little investigation suggests that if I exit the usercontrol by pressing
ENTER to invoke the default Accept button on the form, that neither the
lostfocus or leave events are raised but the validated event is.

Am I therefore safe to put my update code in the validated event? Is this
guaranteed to be fired once and only once every time that my usercontrol is
exited, either by tabbing away, pressing enter or clicking elsewhere on the
form???

Thanks in advance
Simon
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
I'm considering using the LostFocus event. instead of leave.. It looks
like they both get fired? Though it would appear that possibly the Leave
event doesn't get fired in the scenario I describe whereas the LostFocus
even does??? (I've not tested this yet but I'm presuming that it should).

So, to guarantee that my data gets updated, where should I put my updating
code? LostFocus? Leave? or perhaps should I use Validated or
Validating??? Do I need to do the update in multiple events (with the pain
of running the update code twice???)

Hope somebody can ease my confusion!!

Regards
Simon

"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a usercontrol with code in the "leave" event which updates the
final data back into a database.

This works fine except if I have a default "accept" button on a form and
invoke it by pressing the ENTER key on the keyboard. In this case, it
would appear that whilst the code on the button is executing and
therefore presumably the button actually has focus, the leave event in
the user control is not fired.

Should I be interfacing with another event on the usercontrol instead of
the "leave" event.. or is there some other way round the problem?

Thanks in advance
Simon


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
2
by: Cederstrom | last post by:
Hello Group, I have created an ASP.NET page. The page consist of the following items: - Button A - Button B - UserControl When I press Button A, I execute the following code: ViewState =...
2
by: Eric Maia | last post by:
I have two UserControls I am using in a form. These are each also used separately in two other forms. The structure is essentially this: CourseUserControl.ascx - select or enter a course...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
2
by: Frank | last post by:
Hi! I have a really 'simple' problem. I have an .aspx page with 2 textboxes (login & password) and a Submit button. This works very well, i fill in my login and password and simply press the...
0
by: Brad | last post by:
I added an Error event to a web usercontrol (ascx), but when an error is raised in the control it does not get called...only the Application_Error even in the global.asax gets called. The same...
4
by: liups | last post by:
Hi, I have an array of usercontrols, each of the usercontrol has a label and a textbox, I want to do some checking when the textbox loses focus, the code is like this: Private Sub...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.