Auto Postback Handling in controls

Discussion in 'ASP .Net Web Controls' started by HeavyMetal, Jul 13, 2006.

  1. HeavyMetal

    HeavyMetal Guest

    Having trouble handling postbacks when they are coming from an
    asp:textbox auto postback and/or a button click. Is there a way to
    distiguish between the two?

    Details:

    ...Auto postback comes from a text box when user tabs off the box
    (AutoPostback="True"). this text box exists on an ascx page. this
    causes a recalculation of the page. Atlas is being used.

    ...there is a save button on the aspx (aspx hold 2 separate controls).
    if the user does not tab off the box, but wants to save the page, the
    postback from the text box is run first. this causes the user to click
    the save button twice; the second click actually fires the click event
    which is captured.

    ...i have tried various option including callback functions onkeyup to
    recalc the page, but the Atlas appears to interfere

    ...i need to prevent this double-click on the save button.

    Any advise will be appreciated. Thanks.
     
    HeavyMetal, Jul 13, 2006
    #1
    1. Advertising

  2. hi, just noticed your post. This will explain why you are probably facing
    that particular problem.

    http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net


    "HeavyMetal" <> ha scritto nel messaggio
    news:...
    > Having trouble handling postbacks when they are coming from an
    > asp:textbox auto postback and/or a button click. Is there a way to
    > distiguish between the two?
    >
    > Details:
    >
    > ..Auto postback comes from a text box when user tabs off the box
    > (AutoPostback="True"). this text box exists on an ascx page. this
    > causes a recalculation of the page. Atlas is being used.
    >
    > ..there is a save button on the aspx (aspx hold 2 separate controls).
    > if the user does not tab off the box, but wants to save the page, the
    > postback from the text box is run first. this causes the user to click
    > the save button twice; the second click actually fires the click event
    > which is captured.
    >
    > ..i have tried various option including callback functions onkeyup to
    > recalc the page, but the Atlas appears to interfere
    >
    > ..i need to prevent this double-click on the save button.
    >
    > Any advise will be appreciated. Thanks.
    >
     
    Alessandro Zifiglio, Jul 15, 2006
    #2
    1. Advertising

  3. HeavyMetal

    HeavyMetal Guest

    Thanks, but your answer does not quite cover it.

    i need the autopostback to re-calculate numbers on the page. then the
    user has the option of clicking save.

    any other thoughts?

    Alessandro Zifiglio wrote:
    > hi, just noticed your post. This will explain why you are probably facing
    > that particular problem.
    >
    > http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    >
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    >
    > "HeavyMetal" <> ha scritto nel messaggio
    > news:...
    > > Having trouble handling postbacks when they are coming from an
    > > asp:textbox auto postback and/or a button click. Is there a way to
    > > distiguish between the two?
    > >
    > > Details:
    > >
    > > ..Auto postback comes from a text box when user tabs off the box
    > > (AutoPostback="True"). this text box exists on an ascx page. this
    > > causes a recalculation of the page. Atlas is being used.
    > >
    > > ..there is a save button on the aspx (aspx hold 2 separate controls).
    > > if the user does not tab off the box, but wants to save the page, the
    > > postback from the text box is run first. this causes the user to click
    > > the save button twice; the second click actually fires the click event
    > > which is captured.
    > >
    > > ..i have tried various option including callback functions onkeyup to
    > > recalc the page, but the Atlas appears to interfere
    > >
    > > ..i need to prevent this double-click on the save button.
    > >
    > > Any advise will be appreciated. Thanks.
    > >
     
    HeavyMetal, Jul 18, 2006
    #3
  4. quoting what you had stated earlier in your post : "if the user does not tab
    off the box, but wants to save the page, the postback from the text box is
    run first. this causes the user to click the save button twice; the second
    click actually fires the click event which is captured."

    This is happening because the textbox loses focus and if the text in the
    textbox has changed then the textbox postsback, even though your user has
    clicked on a submit button. The postback of your submit button executes the
    second time because this time the text in your textbox has not changed and
    wont fire, allowing your button to postback. If you want to distinguish
    between the two, you can try and check __eventTarget in your requests form
    collection. This should contain the id of textbox that is posting back, if
    its empty then you know its not your textbox posting back but your button :

    If you need to know what submit button posted back then you can do the same
    check in the forms collection but instead of checking __eventTarget, pass
    the id of the submit button whom you want to check for postback. If this
    control did not postback then this will return empty coz only the submit
    button that posted back will be available in the forms collection.

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net

    protected void Page_Load(object sender, EventArgs e)
    {
    if (this.IsPostBack)
    {
    // this should contain the id of your textbox that is posting
    back
    // You can use this with textbox, linkbutton, dropdownlist etc.
    string eventTarget = this.Request.Form["__eventTarget"];
    if (!string.IsNullOrEmpty(eventTarget))
    Response.Write(eventTarget);
    }
    }
    "HeavyMetal" <> ha scritto nel messaggio
    news:...
    > Thanks, but your answer does not quite cover it.
    >
    > i need the autopostback to re-calculate numbers on the page. then the
    > user has the option of clicking save.
    >
    > any other thoughts?
    >
    > Alessandro Zifiglio wrote:
    >> hi, just noticed your post. This will explain why you are probably facing
    >> that particular problem.
    >>
    >> http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    >>
    >> Regards,
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >>
    >> "HeavyMetal" <> ha scritto nel messaggio
    >> news:...
    >> > Having trouble handling postbacks when they are coming from an
    >> > asp:textbox auto postback and/or a button click. Is there a way to
    >> > distiguish between the two?
    >> >
    >> > Details:
    >> >
    >> > ..Auto postback comes from a text box when user tabs off the box
    >> > (AutoPostback="True"). this text box exists on an ascx page. this
    >> > causes a recalculation of the page. Atlas is being used.
    >> >
    >> > ..there is a save button on the aspx (aspx hold 2 separate controls).
    >> > if the user does not tab off the box, but wants to save the page, the
    >> > postback from the text box is run first. this causes the user to click
    >> > the save button twice; the second click actually fires the click event
    >> > which is captured.
    >> >
    >> > ..i have tried various option including callback functions onkeyup to
    >> > recalc the page, but the Atlas appears to interfere
    >> >
    >> > ..i need to prevent this double-click on the save button.
    >> >
    >> > Any advise will be appreciated. Thanks.
    >> >

    >
     
    Alessandro Zifiglio, Jul 18, 2006
    #4
  5. HeavyMetal

    HeavyMetal Guest

    Thanks for all the info - still not working, but more clear as to what
    is happening.

    if the user simply enters something into the textbox, does not tab off
    textbox (does not lose focus), then clicks submit, the postback event
    for the textbox fires because then the textbox loses focus. so, the
    __EVENTTARGET target is still the textbox, even if the submit is
    clicked.

    I have tried to use the CallBack event handler to do the recalculation
    portion, but think that it is conflicting with the Atlas i have on the
    page. If you have any other thoughts, that would be great. If not,
    thanks for the help.

    Alessandro Zifiglio wrote:
    > quoting what you had stated earlier in your post : "if the user does not tab
    > off the box, but wants to save the page, the postback from the text box is
    > run first. this causes the user to click the save button twice; the second
    > click actually fires the click event which is captured."
    >
    > This is happening because the textbox loses focus and if the text in the
    > textbox has changed then the textbox postsback, even though your user has
    > clicked on a submit button. The postback of your submit button executes the
    > second time because this time the text in your textbox has not changed and
    > wont fire, allowing your button to postback. If you want to distinguish
    > between the two, you can try and check __eventTarget in your requests form
    > collection. This should contain the id of textbox that is posting back, if
    > its empty then you know its not your textbox posting back but your button :
    >
    > If you need to know what submit button posted back then you can do the same
    > check in the forms collection but instead of checking __eventTarget, pass
    > the id of the submit button whom you want to check for postback. If this
    > control did not postback then this will return empty coz only the submit
    > button that posted back will be available in the forms collection.
    >
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (this.IsPostBack)
    > {
    > // this should contain the id of your textbox that is posting
    > back
    > // You can use this with textbox, linkbutton, dropdownlist etc.
    > string eventTarget = this.Request.Form["__eventTarget"];
    > if (!string.IsNullOrEmpty(eventTarget))
    > Response.Write(eventTarget);
    > }
    > }
    > "HeavyMetal" <> ha scritto nel messaggio
    > news:...
    > > Thanks, but your answer does not quite cover it.
    > >
    > > i need the autopostback to re-calculate numbers on the page. then the
    > > user has the option of clicking save.
    > >
    > > any other thoughts?
    > >
    > > Alessandro Zifiglio wrote:
    > >> hi, just noticed your post. This will explain why you are probably facing
    > >> that particular problem.
    > >>
    > >> http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    > >>
    > >> Regards,
    > >> Alessandro Zifiglio
    > >> http://www.AsyncUI.net
    > >>
    > >>
    > >> "HeavyMetal" <> ha scritto nel messaggio
    > >> news:...
    > >> > Having trouble handling postbacks when they are coming from an
    > >> > asp:textbox auto postback and/or a button click. Is there a way to
    > >> > distiguish between the two?
    > >> >
    > >> > Details:
    > >> >
    > >> > ..Auto postback comes from a text box when user tabs off the box
    > >> > (AutoPostback="True"). this text box exists on an ascx page. this
    > >> > causes a recalculation of the page. Atlas is being used.
    > >> >
    > >> > ..there is a save button on the aspx (aspx hold 2 separate controls).
    > >> > if the user does not tab off the box, but wants to save the page, the
    > >> > postback from the text box is run first. this causes the user to click
    > >> > the save button twice; the second click actually fires the click event
    > >> > which is captured.
    > >> >
    > >> > ..i have tried various option including callback functions onkeyup to
    > >> > recalc the page, but the Atlas appears to interfere
    > >> >
    > >> > ..i need to prevent this double-click on the save button.
    > >> >
    > >> > Any advise will be appreciated. Thanks.
    > >> >

    > >
     
    HeavyMetal, Jul 18, 2006
    #5
  6. hi, i'm afraid i dont have an out of the box solution to your problem. I can
    only try and use some creativity, which might look a bit dirty, but it does
    the job well. I dont think you can find a more elegant solution to this
    problem. =P

    what i am doing in the following 2 lines of js code is disabling the
    postback on the textbox if the user did not tab out of the textbox or hit
    enter. So it wont fire when the textbox loses focus. Also as you can see, i
    have hijacked the className property of the textbox(input element). If you
    are using a class name on your textbox you can try and exchange className
    with the 'title' property.

    if (!this.IsPostBack)
    {
    this.TextBox1.Attributes.Add("onkeydown", "if (event.keyCode ==
    09 || event.keyCode == 13) this.className = 'postback';");
    this.TextBox1.Attributes.Add("onchange", "if (this.className !=
    'postback') return false; else this.className = '';");
    }


    good luck.
    Regards,

    Alessandro Zifiglio
    http://www.AsyncUI.net

    "HeavyMetal" <> ha scritto nel messaggio
    news:...
    > Thanks for all the info - still not working, but more clear as to what
    > is happening.
    >
    > if the user simply enters something into the textbox, does not tab off
    > textbox (does not lose focus), then clicks submit, the postback event
    > for the textbox fires because then the textbox loses focus. so, the
    > __EVENTTARGET target is still the textbox, even if the submit is
    > clicked.
    >
    > I have tried to use the CallBack event handler to do the recalculation
    > portion, but think that it is conflicting with the Atlas i have on the
    > page. If you have any other thoughts, that would be great. If not,
    > thanks for the help.
    >
    > Alessandro Zifiglio wrote:
    >> quoting what you had stated earlier in your post : "if the user does not
    >> tab
    >> off the box, but wants to save the page, the postback from the text box
    >> is
    >> run first. this causes the user to click the save button twice; the
    >> second
    >> click actually fires the click event which is captured."
    >>
    >> This is happening because the textbox loses focus and if the text in the
    >> textbox has changed then the textbox postsback, even though your user has
    >> clicked on a submit button. The postback of your submit button executes
    >> the
    >> second time because this time the text in your textbox has not changed
    >> and
    >> wont fire, allowing your button to postback. If you want to distinguish
    >> between the two, you can try and check __eventTarget in your requests
    >> form
    >> collection. This should contain the id of textbox that is posting back,
    >> if
    >> its empty then you know its not your textbox posting back but your button
    >> :
    >>
    >> If you need to know what submit button posted back then you can do the
    >> same
    >> check in the forms collection but instead of checking __eventTarget, pass
    >> the id of the submit button whom you want to check for postback. If this
    >> control did not postback then this will return empty coz only the submit
    >> button that posted back will be available in the forms collection.
    >>
    >> Regards,
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> if (this.IsPostBack)
    >> {
    >> // this should contain the id of your textbox that is posting
    >> back
    >> // You can use this with textbox, linkbutton, dropdownlist
    >> etc.
    >> string eventTarget = this.Request.Form["__eventTarget"];
    >> if (!string.IsNullOrEmpty(eventTarget))
    >> Response.Write(eventTarget);
    >> }
    >> }
    >> "HeavyMetal" <> ha scritto nel messaggio
    >> news:...
    >> > Thanks, but your answer does not quite cover it.
    >> >
    >> > i need the autopostback to re-calculate numbers on the page. then the
    >> > user has the option of clicking save.
    >> >
    >> > any other thoughts?
    >> >
    >> > Alessandro Zifiglio wrote:
    >> >> hi, just noticed your post. This will explain why you are probably
    >> >> facing
    >> >> that particular problem.
    >> >>
    >> >> http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    >> >>
    >> >> Regards,
    >> >> Alessandro Zifiglio
    >> >> http://www.AsyncUI.net
    >> >>
    >> >>
    >> >> "HeavyMetal" <> ha scritto nel messaggio
    >> >> news:...
    >> >> > Having trouble handling postbacks when they are coming from an
    >> >> > asp:textbox auto postback and/or a button click. Is there a way to
    >> >> > distiguish between the two?
    >> >> >
    >> >> > Details:
    >> >> >
    >> >> > ..Auto postback comes from a text box when user tabs off the box
    >> >> > (AutoPostback="True"). this text box exists on an ascx page. this
    >> >> > causes a recalculation of the page. Atlas is being used.
    >> >> >
    >> >> > ..there is a save button on the aspx (aspx hold 2 separate
    >> >> > controls).
    >> >> > if the user does not tab off the box, but wants to save the page,
    >> >> > the
    >> >> > postback from the text box is run first. this causes the user to
    >> >> > click
    >> >> > the save button twice; the second click actually fires the click
    >> >> > event
    >> >> > which is captured.
    >> >> >
    >> >> > ..i have tried various option including callback functions onkeyup
    >> >> > to
    >> >> > recalc the page, but the Atlas appears to interfere
    >> >> >
    >> >> > ..i need to prevent this double-click on the save button.
    >> >> >
    >> >> > Any advise will be appreciated. Thanks.
    >> >> >
    >> >

    >
     
    Alessandro Zifiglio, Jul 19, 2006
    #6
  7. HeavyMetal

    HeavyMetal Guest

    That helped - pointed me in the right direction.

    i am using VB, so in the asp textbox i used the 2 attributes below. i
    did this because the textbox actually resides in a gridview. this
    allows the tab to do a postback and recalculate the page. it also
    allows the Save button to do its own postback.

    onkeydown="if (event.keyCode == 9 || event.keyCode == 13)
    this.className = 'postback';"
    onchange="if (this.className != 'postback') {return false;} else
    {this.className = ''; __doPostBack(this);}"

    thanks for all your info. problem solved.


    Alessandro Zifiglio wrote:
    > hi, i'm afraid i dont have an out of the box solution to your problem. I can
    > only try and use some creativity, which might look a bit dirty, but it does
    > the job well. I dont think you can find a more elegant solution to this
    > problem. =P
    >
    > what i am doing in the following 2 lines of js code is disabling the
    > postback on the textbox if the user did not tab out of the textbox or hit
    > enter. So it wont fire when the textbox loses focus. Also as you can see, i
    > have hijacked the className property of the textbox(input element). If you
    > are using a class name on your textbox you can try and exchange className
    > with the 'title' property.
    >
    > if (!this.IsPostBack)
    > {
    > this.TextBox1.Attributes.Add("onkeydown", "if (event.keyCode ==
    > 09 || event.keyCode == 13) this.className = 'postback';");
    > this.TextBox1.Attributes.Add("onchange", "if (this.className !=
    > 'postback') return false; else this.className = '';");
    > }
    >
    >
    > good luck.
    > Regards,
    >
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    > "HeavyMetal" <> ha scritto nel messaggio
    > news:...
    > > Thanks for all the info - still not working, but more clear as to what
    > > is happening.
    > >
    > > if the user simply enters something into the textbox, does not tab off
    > > textbox (does not lose focus), then clicks submit, the postback event
    > > for the textbox fires because then the textbox loses focus. so, the
    > > __EVENTTARGET target is still the textbox, even if the submit is
    > > clicked.
    > >
    > > I have tried to use the CallBack event handler to do the recalculation
    > > portion, but think that it is conflicting with the Atlas i have on the
    > > page. If you have any other thoughts, that would be great. If not,
    > > thanks for the help.
    > >
    > > Alessandro Zifiglio wrote:
    > >> quoting what you had stated earlier in your post : "if the user does not
    > >> tab
    > >> off the box, but wants to save the page, the postback from the text box
    > >> is
    > >> run first. this causes the user to click the save button twice; the
    > >> second
    > >> click actually fires the click event which is captured."
    > >>
    > >> This is happening because the textbox loses focus and if the text in the
    > >> textbox has changed then the textbox postsback, even though your user has
    > >> clicked on a submit button. The postback of your submit button executes
    > >> the
    > >> second time because this time the text in your textbox has not changed
    > >> and
    > >> wont fire, allowing your button to postback. If you want to distinguish
    > >> between the two, you can try and check __eventTarget in your requests
    > >> form
    > >> collection. This should contain the id of textbox that is posting back,
    > >> if
    > >> its empty then you know its not your textbox posting back but your button
    > >> :
    > >>
    > >> If you need to know what submit button posted back then you can do the
    > >> same
    > >> check in the forms collection but instead of checking __eventTarget, pass
    > >> the id of the submit button whom you want to check for postback. If this
    > >> control did not postback then this will return empty coz only the submit
    > >> button that posted back will be available in the forms collection.
    > >>
    > >> Regards,
    > >> Alessandro Zifiglio
    > >> http://www.AsyncUI.net
    > >>
    > >> protected void Page_Load(object sender, EventArgs e)
    > >> {
    > >> if (this.IsPostBack)
    > >> {
    > >> // this should contain the id of your textbox that is posting
    > >> back
    > >> // You can use this with textbox, linkbutton, dropdownlist
    > >> etc.
    > >> string eventTarget = this.Request.Form["__eventTarget"];
    > >> if (!string.IsNullOrEmpty(eventTarget))
    > >> Response.Write(eventTarget);
    > >> }
    > >> }
    > >> "HeavyMetal" <> ha scritto nel messaggio
    > >> news:...
    > >> > Thanks, but your answer does not quite cover it.
    > >> >
    > >> > i need the autopostback to re-calculate numbers on the page. then the
    > >> > user has the option of clicking save.
    > >> >
    > >> > any other thoughts?
    > >> >
    > >> > Alessandro Zifiglio wrote:
    > >> >> hi, just noticed your post. This will explain why you are probably
    > >> >> facing
    > >> >> that particular problem.
    > >> >>
    > >> >> http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    > >> >>
    > >> >> Regards,
    > >> >> Alessandro Zifiglio
    > >> >> http://www.AsyncUI.net
    > >> >>
    > >> >>
    > >> >> "HeavyMetal" <> ha scritto nel messaggio
    > >> >> news:...
    > >> >> > Having trouble handling postbacks when they are coming from an
    > >> >> > asp:textbox auto postback and/or a button click. Is there a way to
    > >> >> > distiguish between the two?
    > >> >> >
    > >> >> > Details:
    > >> >> >
    > >> >> > ..Auto postback comes from a text box when user tabs off the box
    > >> >> > (AutoPostback="True"). this text box exists on an ascx page. this
    > >> >> > causes a recalculation of the page. Atlas is being used.
    > >> >> >
    > >> >> > ..there is a save button on the aspx (aspx hold 2 separate
    > >> >> > controls).
    > >> >> > if the user does not tab off the box, but wants to save the page,
    > >> >> > the
    > >> >> > postback from the text box is run first. this causes the user to
    > >> >> > click
    > >> >> > the save button twice; the second click actually fires the click
    > >> >> > event
    > >> >> > which is captured.
    > >> >> >
    > >> >> > ..i have tried various option including callback functions onkeyup
    > >> >> > to
    > >> >> > recalc the page, but the Atlas appears to interfere
    > >> >> >
    > >> >> > ..i need to prevent this double-click on the save button.
    > >> >> >
    > >> >> > Any advise will be appreciated. Thanks.
    > >> >> >
    > >> >

    > >
     
    HeavyMetal, Jul 20, 2006
    #7
  8. You are welcome.

    Have a good day,
    Alessandro Zifiglio
    http://www.AsyncUI.net


    "HeavyMetal" <> ha scritto nel messaggio
    news:...
    > That helped - pointed me in the right direction.
    >
    > i am using VB, so in the asp textbox i used the 2 attributes below. i
    > did this because the textbox actually resides in a gridview. this
    > allows the tab to do a postback and recalculate the page. it also
    > allows the Save button to do its own postback.
    >
    > onkeydown="if (event.keyCode == 9 || event.keyCode == 13)
    > this.className = 'postback';"
    > onchange="if (this.className != 'postback') {return false;} else
    > {this.className = ''; __doPostBack(this);}"
    >
    > thanks for all your info. problem solved.
    >
    >
    > Alessandro Zifiglio wrote:
    >> hi, i'm afraid i dont have an out of the box solution to your problem. I
    >> can
    >> only try and use some creativity, which might look a bit dirty, but it
    >> does
    >> the job well. I dont think you can find a more elegant solution to this
    >> problem. =P
    >>
    >> what i am doing in the following 2 lines of js code is disabling the
    >> postback on the textbox if the user did not tab out of the textbox or hit
    >> enter. So it wont fire when the textbox loses focus. Also as you can see,
    >> i
    >> have hijacked the className property of the textbox(input element). If
    >> you
    >> are using a class name on your textbox you can try and exchange className
    >> with the 'title' property.
    >>
    >> if (!this.IsPostBack)
    >> {
    >> this.TextBox1.Attributes.Add("onkeydown", "if (event.keyCode
    >> ==
    >> 09 || event.keyCode == 13) this.className = 'postback';");
    >> this.TextBox1.Attributes.Add("onchange", "if (this.className
    >> !=
    >> 'postback') return false; else this.className = '';");
    >> }
    >>
    >>
    >> good luck.
    >> Regards,
    >>
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >> "HeavyMetal" <> ha scritto nel messaggio
    >> news:...
    >> > Thanks for all the info - still not working, but more clear as to what
    >> > is happening.
    >> >
    >> > if the user simply enters something into the textbox, does not tab off
    >> > textbox (does not lose focus), then clicks submit, the postback event
    >> > for the textbox fires because then the textbox loses focus. so, the
    >> > __EVENTTARGET target is still the textbox, even if the submit is
    >> > clicked.
    >> >
    >> > I have tried to use the CallBack event handler to do the recalculation
    >> > portion, but think that it is conflicting with the Atlas i have on the
    >> > page. If you have any other thoughts, that would be great. If not,
    >> > thanks for the help.
    >> >
    >> > Alessandro Zifiglio wrote:
    >> >> quoting what you had stated earlier in your post : "if the user does
    >> >> not
    >> >> tab
    >> >> off the box, but wants to save the page, the postback from the text
    >> >> box
    >> >> is
    >> >> run first. this causes the user to click the save button twice; the
    >> >> second
    >> >> click actually fires the click event which is captured."
    >> >>
    >> >> This is happening because the textbox loses focus and if the text in
    >> >> the
    >> >> textbox has changed then the textbox postsback, even though your user
    >> >> has
    >> >> clicked on a submit button. The postback of your submit button
    >> >> executes
    >> >> the
    >> >> second time because this time the text in your textbox has not changed
    >> >> and
    >> >> wont fire, allowing your button to postback. If you want to
    >> >> distinguish
    >> >> between the two, you can try and check __eventTarget in your requests
    >> >> form
    >> >> collection. This should contain the id of textbox that is posting
    >> >> back,
    >> >> if
    >> >> its empty then you know its not your textbox posting back but your
    >> >> button
    >> >> :
    >> >>
    >> >> If you need to know what submit button posted back then you can do the
    >> >> same
    >> >> check in the forms collection but instead of checking __eventTarget,
    >> >> pass
    >> >> the id of the submit button whom you want to check for postback. If
    >> >> this
    >> >> control did not postback then this will return empty coz only the
    >> >> submit
    >> >> button that posted back will be available in the forms collection.
    >> >>
    >> >> Regards,
    >> >> Alessandro Zifiglio
    >> >> http://www.AsyncUI.net
    >> >>
    >> >> protected void Page_Load(object sender, EventArgs e)
    >> >> {
    >> >> if (this.IsPostBack)
    >> >> {
    >> >> // this should contain the id of your textbox that is
    >> >> posting
    >> >> back
    >> >> // You can use this with textbox, linkbutton, dropdownlist
    >> >> etc.
    >> >> string eventTarget = this.Request.Form["__eventTarget"];
    >> >> if (!string.IsNullOrEmpty(eventTarget))
    >> >> Response.Write(eventTarget);
    >> >> }
    >> >> }
    >> >> "HeavyMetal" <> ha scritto nel messaggio
    >> >> news:...
    >> >> > Thanks, but your answer does not quite cover it.
    >> >> >
    >> >> > i need the autopostback to re-calculate numbers on the page. then
    >> >> > the
    >> >> > user has the option of clicking save.
    >> >> >
    >> >> > any other thoughts?
    >> >> >
    >> >> > Alessandro Zifiglio wrote:
    >> >> >> hi, just noticed your post. This will explain why you are probably
    >> >> >> facing
    >> >> >> that particular problem.
    >> >> >>
    >> >> >> http://groups.google.com/group/micr...d submit button&rnum=1&hl=en#be9a7dba9ed1f80e
    >> >> >>
    >> >> >> Regards,
    >> >> >> Alessandro Zifiglio
    >> >> >> http://www.AsyncUI.net
    >> >> >>
    >> >> >>
    >> >> >> "HeavyMetal" <> ha scritto nel messaggio
    >> >> >> news:...
    >> >> >> > Having trouble handling postbacks when they are coming from an
    >> >> >> > asp:textbox auto postback and/or a button click. Is there a way
    >> >> >> > to
    >> >> >> > distiguish between the two?
    >> >> >> >
    >> >> >> > Details:
    >> >> >> >
    >> >> >> > ..Auto postback comes from a text box when user tabs off the box
    >> >> >> > (AutoPostback="True"). this text box exists on an ascx page. this
    >> >> >> > causes a recalculation of the page. Atlas is being used.
    >> >> >> >
    >> >> >> > ..there is a save button on the aspx (aspx hold 2 separate
    >> >> >> > controls).
    >> >> >> > if the user does not tab off the box, but wants to save the page,
    >> >> >> > the
    >> >> >> > postback from the text box is run first. this causes the user to
    >> >> >> > click
    >> >> >> > the save button twice; the second click actually fires the click
    >> >> >> > event
    >> >> >> > which is captured.
    >> >> >> >
    >> >> >> > ..i have tried various option including callback functions
    >> >> >> > onkeyup
    >> >> >> > to
    >> >> >> > recalc the page, but the Atlas appears to interfere
    >> >> >> >
    >> >> >> > ..i need to prevent this double-click on the save button.
    >> >> >> >
    >> >> >> > Any advise will be appreciated. Thanks.
    >> >> >> >
    >> >> >
    >> >

    >
     
    Alessandro Zifiglio, Jul 21, 2006
    #8
    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. Psych971
    Replies:
    5
    Views:
    4,636
    bruce barker
    Dec 17, 2004
  2. =?Utf-8?B?V2FyYW4=?=

    Auto-Suggested Textbox like google auto suggest

    =?Utf-8?B?V2FyYW4=?=, Apr 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    8,535
    inrakeshworld
    Jul 27, 2007
  3. linkswanted
    Replies:
    1
    Views:
    936
  4. Replies:
    0
    Views:
    177
  5. Wael_Bakr

    stop postback in postback events for server controls ??

    Wael_Bakr, Nov 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    509
    Wael_Bakr
    Nov 30, 2005
Loading...

Share This Page