asp:Button client-side events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    #1

    asp:Button client-side events

    I need to intercept the Click event of a asp:Button on the client side
    so that i can disable it after they've clicked it... HOW can i do
    this??

    I was thinking of making the button an HTML button and handling the
    __doPostback myself... BUT, my page does have some asp:Validator
    controls on it, so I don't know how to mimic the logic for calling the
    validation functions properly.

    Is there ANY way i can make the asp:Button call some of MY Javascript
    before it calls the .Net validation/postback stuff??

    jeffpriz
  • Ivan

    #2
    asp:Button client-side events

    I'm not sure i've understood your problem.... anyway, you
    can try the set causeValidation to false and then when the
    buttons is clicked you disable it.
    Ivan
    [color=blue]
    >-----Original Message-----
    >I need to intercept the Click event of a asp:Button on[/color]
    the client side[color=blue]
    >so that i can disable it after they've clicked it... HOW[/color]
    can i do[color=blue]
    >this??
    >
    >I was thinking of making the button an HTML button and[/color]
    handling the[color=blue]
    >__doPostback myself... BUT, my page does have some[/color]
    asp:Validator[color=blue]
    >controls on it, so I don't know how to mimic the logic[/color]
    for calling the[color=blue]
    >validation functions properly.
    >
    >Is there ANY way i can make the asp:Button call some of[/color]
    MY Javascript[color=blue]
    >before it calls the .Net validation/postback stuff??
    >
    >jeffpriz
    >.
    >[/color]

    Comment

    • Teemu Keiski

      #3
      Re: asp:Button client-side events

      For client-side validation, if you check the code when there are buttons, is
      Page_ClientVali date the relevant function. The call for it is exactly of
      form:

      if (typeof(Page_Cl ientValidate) == 'function') Page_ClientVali date();

      --
      Teemu Keiski
      MCP, Microsoft MVP (ASP.NET), AspInsiders member
      ASP.NET Forum Moderator, AspAlliance Columnist

      "Jeff" <jeffpriz@yahoo .com> wrote in message
      news:cd5d6d81.0 310240647.27f3a b14@posting.goo gle.com...[color=blue]
      > I need to intercept the Click event of a asp:Button on the client side
      > so that i can disable it after they've clicked it... HOW can i do
      > this??
      >
      > I was thinking of making the button an HTML button and handling the
      > __doPostback myself... BUT, my page does have some asp:Validator
      > controls on it, so I don't know how to mimic the logic for calling the
      > validation functions properly.
      >
      > Is there ANY way i can make the asp:Button call some of MY Javascript
      > before it calls the .Net validation/postback stuff??
      >
      > jeffpriz[/color]


      Comment

      • David

        #4
        Re: asp:Button client-side events

        In article <cd5d6d81.03102 40647.27f3ab14@ posting.google. com>, Jeff wrote:[color=blue]
        > I need to intercept the Click event of a asp:Button on the client side
        > so that i can disable it after they've clicked it... HOW can i do
        > this??
        >
        > I was thinking of making the button an HTML button and handling the
        > __doPostback myself... BUT, my page does have some asp:Validator
        > controls on it, so I don't know how to mimic the logic for calling the
        > validation functions properly.
        >
        > Is there ANY way i can make the asp:Button call some of MY Javascript
        > before it calls the .Net validation/postback stuff??[/color]

        If you set the onclick attribute of the button to your own code in
        Page_Load (e.g. Button1.Attribu tes["onclick"] = "this.disab led =
        true;";), then ASP.NET will add the validation stuff onto the end of
        your own code. But if you disable the button before validation there's
        the danger that client-side validation will fail leaving your user with
        a disabled button, plus there's the problem that a disabled button won't
        send it's name/value info in the submitted form, which means that the
        server side event handler will be missed.

        If you're just trying to stop the user from pressing the submit button
        multiple times, you might be interested in the OneClick control from
        http://www.metabuilders.com (warning, I haven't used this control at
        all, although other controls from the site have worked great for me).
        There's a good discussion of the problem there as well.

        PS. No, I'm not affiliated with metabuilders in any way.


        --
        David
        dfoster at
        hotpop dot com

        Comment

        Working...