Expert advice needed on some strange event handling

Discussion in 'ASP .Net' started by Tony, May 24, 2006.

  1. Tony

    Tony Guest

    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.
    Tony, May 24, 2006
    #1
    1. Advertising

  2. Tony

    Tony Guest

    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
    Tony, May 24, 2006
    #2
    1. Advertising

  3. 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
    >
    >
    >
    =?Utf-8?B?cmVjb2lsQGNvbW11bml0eS5ub3NwYW0=?=, May 24, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Smith

    Expert advice needed

    John Smith, Aug 16, 2003, in forum: C++
    Replies:
    7
    Views:
    523
    Ahti Legonkov
    Aug 18, 2003
  2. Replies:
    9
    Views:
    396
    Default User
    Apr 28, 2005
  3. Amit_Basnak
    Replies:
    3
    Views:
    294
    Alf P. Steinbach
    Nov 16, 2006
  4. Smith

    Expert advice needed!

    Smith, Nov 9, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    332
    Mark Rae [MVP]
    Nov 9, 2007
  5. Tony

    Expert advice needed on some strange event handling

    Tony, May 24, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    117
Loading...

Share This Page