472,374 Members | 1,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

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 2416
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JCE | last post by:
I need to programmatically invoke an asp:Button click event from a javascript function. The page containing the script and the button is the HTML page associated with a WebUserControl-derived...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
4
by: hb | last post by:
Hi, When I add an asp:button (ex: id=btnLog) on home.aspx, I need to create btnLog_Click() event in home.aspx.cs, and also link this event and the button in OnInit() method by adding:...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
5
by: Jim in Arizona | last post by:
I have a site that uses frames. I made an aspx form with an asp:button control with Onclick=test. The test sub is: Sub Test(ByVal sender As Object, ByVal e As System.EventArgs) ...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
7
by: Lam | last post by:
I want to dynamic generate a asp:button in C# class, not in the HTML code so that it can call the methods in the c# class, I try to use "Response.Write("<asp:button...>") it didn't show the button...
3
by: JV | last post by:
This is for anyone who has tackled the accessibility issue on their web site (and if you haven't, I bet you will in future). Apparently the asp:button control always renders as '<input...
3
by: Randall Parker | last post by:
I have this element in an asp:DataGrid: <asp:TemplateColumn HeaderText="Edit Record Button"> <ItemTemplate> <asp:Button ID='<%# "Edit" + DataBinder.Eval(Container, "DataItem.owner_serial_num")...
5
by: Doogie | last post by:
Hi, I am trying to access the visible property of an ASP button inside javascript to no avail. Here's what my button control looks like: <asp:Button id="btnAcceptTrips" name="btnAcceptTrips"...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.