473,408 Members | 2,888 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,408 software developers and data experts.

TexChanged event and Click event confusion

Sometimes, I use "TextBox_TextChanged" event to auto fill in other text box
once user tab out from the search box.
i.e. connect to database and use the field to search out record and then
fill in other text box.
However, I also use a "Update" button to update the database once click it.
The problem is that I type something in
text box and then click button to update. The TextBox_TextChanged event is
trigger before the button click event is trigger.
How to solve this problem? Thanks.
Nov 19 '05 #1
3 1431
Hi,

the event that is by the postbacking control (which causes the postback)
will be running last always. There's no way changing that. For TextBox the
TextChanged event is just signal of change in the state, while with Button
it is indication that this was clicked and a postback happened.

However, you certainly can put up a boolean flag which is set to true in
TextChanged, and check that in Button_Click and then do what needs to be
done based on it (e.g gives you knowledge if something was changed in the
TB).

It's also possible to develop a custom TextBox control which would indicate
the change in state earlier than on TextChanged event, however that's not
very helpful int his scenario, if I understand correctly.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #2
Max
ok, but the onclick button fire before the textchange event.

"Teemu Keiski" <jo****@aspalliance.com> ha scritto nel messaggio
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Hi,

the event that is by the postbacking control (which causes the postback)
will be running last always. There's no way changing that. For TextBox the
TextChanged event is just signal of change in the state, while with Button
it is indication that this was clicked and a postback happened.

However, you certainly can put up a boolean flag which is set to true in
TextChanged, and check that in Button_Click and then do what needs to be
done based on it (e.g gives you knowledge if something was changed in the
TB).

It's also possible to develop a custom TextBox control which would
indicate the change in state earlier than on TextChanged event, however
that's not very helpful int his scenario, if I understand correctly.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #3
If you mean onclick at client (browser), yes, it does but at server-side it
is the postbacking control whose event fires last. If you have TextBox on
the Page and a Button, you change the text and click Button, it is the
Button's Click event from those two which fires the last. If TextBox is
autopostbacking (AutoPostback=true), there should still be no problems as
then those happen as two totally separate steps.

See following Page lifecycle diagram. It covers also ASP.NET v20 but
important is to note that RaiseChangedEvents runs before RaisePostBackEvent
(it is the same in v1). TextChanged event is one of those changed events
while Button's Click is a postback event.

http://hydrate.typepad.com/leo/2004/...pnet_v20_.html
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #4

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

Similar topics

4
by: Rulin Hong | last post by:
According to OO, interface is just a bunch of definitions, no implementation at all. It's also true when we write our own code in .NET. But I find every interface provided by .NET has specific...
2
by: Ron Dahl | last post by:
I'm very confused on how the Protected Overrides works. I created a new project with a new form1 and a new datagrid called myDataGrid. I created a simple DataTable and put 5 rows and 5 columns of...
1
by: archana | last post by:
Hi all, I am having one confusion regarding changing cursor to wait cursor I am providing auto refreshing facility for listview using timer. So what i am doing is when auto refreshing is in...
8
by: carlos123 | last post by:
hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has greg john joe 54343 45777...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.