473,549 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2513
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_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" <je******@yahoo .com> wrote in message
news:cd******** *************** ***@posting.goo gle.com...
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.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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9023
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 object (both the HTML and control are built in the same .ascx file) The target button simply fires an event in the WebUserControl-derived object. So,...
4
2276
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 lower area of the form. on the lower area i have validators for validating input.
4
2555
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: this.btnLog.Click +=new System.EventHandler(this.btnLog_Click); Now, I need to generate some asp:button dynamically in an asp:table, and assign the event...
1
3625
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 RuizCJ
5
3554
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) Response.Redirect("http://webserver/policies/pppindex.htm target=_blank") End Sub Of course, this will not work. Is there some way I can get a similar result
8
3872
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 TABLE!?! When I move the button outside the table, it works just fine. Inside the table, it doesn't. What gives?
7
1926
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 Can anyone help? Thanks a lot
3
2050
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 type="submit" ....' (a.k.a. submit button) and this can have a big impact on your web site's keyboard handling. Default IE behavior when you have the...
3
2389
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") %>' CommandName="EquipmentEdit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.owner_serial_num") %>' Runat="server"
5
16295
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" runat="server" Text="Accept Trips" Visible="False"> Here's my test method: function test(checkbox)
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.