468,510 Members | 1,803 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,510 developers. It's quick & easy.

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
Nov 17 '05 #1
3 2307
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
-----Original Message-----
I need to intercept the Click event of a asp:Button on the client sideso that i can disable it after they've clicked it... HOW can i dothis??

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

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

jeffpriz
.

Nov 17 '05 #2
For client-side validation, if you check the code when there are buttons, is
Page_ClientValidate the relevant function. The call for it is exactly of
form:

if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();

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

"Jeff" <je******@yahoo.com> wrote in message
news:cd**************************@posting.google.c om...
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

Nov 17 '05 #3
In article <cd**************************@posting.google.com >, Jeff wrote:
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??


If you set the onclick attribute of the button to your own code in
Page_Load (e.g. Button1.Attributes["onclick"] = "this.disabled =
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
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JCE | last post: by
1 post views Thread by RUIZCJ | last post: by
5 posts views Thread by Jim in Arizona | last post: by
7 posts views Thread by Lam | last post: by
3 posts views Thread by JV | last post: by
3 posts views Thread by Randall Parker | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.