Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Expert advice needed on some strange event handling

Reply
Thread Tools

Expert advice needed on some strange event handling

 
 
Tony
Guest
Posts: n/a
 
      05-24-2006
I have a WebApp with 3 text boxes and 1 button, as described below. Can
someone please explain why the bad scenarios are occurring and

better still if they can be prevented or worked-around? Please excuse my
lengthy message.


+++ Web Form Structure +++

[TextBox1] TextChanged event wired up.
[TextBox2] TextChanged event wired up and property AutoPostBack=True.
[TextBox3]
<Button1> Click event wired up and property AccessKey=B.


+++ Scenario A +++

[a ] press tab key
[b ] press tab key <- post back occurs here
[ ]
<Button1>

Server Event Trace:
TextBox1_TextChanged
TextBox2_TextChanged

Good Result:
Couldn't ask for anything more here


+++ Scenario B +++

Note: This scenario also occurs by pressing the Button1's AccessKey (alt+B)
instead of pressing the enter key.

[c ] press tab key
[d ] press enter key <- post back occurs here
[ ]
<Button1>

Server Event Trace:
TextBox1_TextChanged
TextBox2_TextChanged
TextBox1_TextChanged
TextBox2_TextChanged
Button1_Click

Bad Result:
TextBox1&2_TextChanged events fired twice. This is probably because of two
seperate post backs (TextBox2's AutoPostBack=True

and button's Click). Is there a way of avoiding two TextChange events from
occuring? Setting AutoPostBack=False is not an option.


+++ Scenario C +++

[e ] press tab key
[f ]
[ ]
<Button1> click <- post back occurs here

Server Event Trace:
TextBox1_TextChanged
TextBox2_TextChanged

Bad Result:
Missing Button1_Click event. This could potentially be a problem if there's
no work-around. Any suggestions here?


Many thanks in advance,
Tony.


 
Reply With Quote
 
 
 
 
Tony
Guest
Posts: n/a
 
      05-24-2006
I'd better summarise my previous lengthy message - even I'm getting confused


1. When a web form has a text field with AutoPostBack=True, we seem to be
getting twice the number of post backs on the TextChanged event - refer to
scenario B.
2. There are situations when a button click event is missed when a web form
has a text field with AutoPostBack=True - refer to scenario C.

Does anyone know of any work-arounds addressing these two scenarios?

Thanks


 
Reply With Quote
 
 
 
 
recoil@community.nospam
Guest
Posts: n/a
 
      05-24-2006
Hello Tony. My advice is to not use the AutoPost Back event on a text box.
You really shouldn't be doing that as it is a) very server /network consuming
and b) it can frustrate the user on many levels. If you can try to explain
what you are trying to accomplish with the auto post backs and the button
clicks I can try to see if there are ways around this or iuf there are easy
js methods that can do what you are trying to do.

Hope this helps.

"Tony" wrote:

> I'd better summarise my previous lengthy message - even I'm getting confused
>
>
> 1. When a web form has a text field with AutoPostBack=True, we seem to be
> getting twice the number of post backs on the TextChanged event - refer to
> scenario B.
> 2. There are situations when a button click event is missed when a web form
> has a text field with AutoPostBack=True - refer to scenario C.
>
> Does anyone know of any work-arounds addressing these two scenarios?
>
> Thanks
>
>
>

 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      05-26-2006
Thanks for replying.

AutoPostBack's on text fields were a matter of convenience on the user's
behalf. In order for certain validation logic to be performed, it saved them
the trouble of pressing a button after text was changed in the field. Under
some conditions, validating a text field right after it's been edited (user
leaves the field) can also be a blessing, in that it may save the user
completing the entire form and hitting the submit button to only realise
that the text field cannot be accepted. And possibly worst the context of
the entire form is now void and they may have to redo it all again in a
different context.

I guess there are work-arounds in these extreme situations by turning
AutoPostBack's off by have an explicit button next to the field staing the
obvious "Validate Entry Now". But if the two bad scenarios (B & C) could be
resolved by having AutoPostBack's on, then that would be my preferred
resolution.

Tony

<> wrote in message
news:A8A35D33-282A-4B01-84DC-...
> Hello Tony. My advice is to not use the AutoPost Back event on a text box.
> You really shouldn't be doing that as it is a) very server /network
> consuming
> and b) it can frustrate the user on many levels. If you can try to explain
> what you are trying to accomplish with the auto post backs and the button
> clicks I can try to see if there are ways around this or iuf there are
> easy
> js methods that can do what you are trying to do.
>
> Hope this helps.
>
> "Tony" wrote:
>
>> I'd better summarise my previous lengthy message - even I'm getting
>> confused
>>
>>
>> 1. When a web form has a text field with AutoPostBack=True, we seem to be
>> getting twice the number of post backs on the TextChanged event - refer
>> to
>> scenario B.
>> 2. There are situations when a button click event is missed when a web
>> form
>> has a text field with AutoPostBack=True - refer to scenario C.
>>
>> Does anyone know of any work-arounds addressing these two scenarios?
>>
>> Thanks
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expert advice needed on C++ errors while doing make Amit_Basnak C++ 3 11-16-2006 05:12 PM
Expert advice needed on some strange event handling Tony ASP .Net 2 05-24-2006 03:41 PM
Expert advice needed (We were all new once) hoggmeister@gmail.com C Programming 9 04-28-2005 03:56 PM
Advice from an expert needed! Andy½ MCSE 4 03-01-2004 11:21 PM
Expert advice needed John Smith C++ 7 08-18-2003 10:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57