Re: add code to all button on my asp.net website?

2011-04-20 Thread David Connors
On Wed, Apr 20, 2011 at 11:24 PM, Jamie Surman wrote:

> IMHO the value in doing this on the client rather than server side is the
> reduction in traffic between client and server.
>

You can do it on the client-side if you wish but you ALSO have to do it on
the server-side for the reason's Richard discussed previously.

-- 
*David Connors* | da...@codify.com | www.codify.com
Software Engineer
Codify Pty Ltd
Phone: +61 (7) 3210 6268 | Facsimile: +61 (7) 3210 6269 | Mobile: +61 417
189 363
V-Card: https://www.codify.com/cards/davidconnors
Address Info: https://www.codify.com/contact


Re: add code to all button on my asp.net website?

2011-04-20 Thread Jamie Surman
My 2c, easily done via the AJAX client library. I use the following code for 
cancelling button clicks during an async postback (ie inside an Update Panel)
(Note the client library is only available if you have a scriptmanager control 
on your form)

-Add the following javascript to your page
 function pageLoad() {

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(cancelPostBack);

}

function cancelPostBack(sender, args) {
if 
(Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) 
{

args.set_cancel(true); //cancels any clicks if we are already 
processing one
}
}   


IMHO the value in doing this on the client rather than server side is the 
reduction in traffic between client and server.

Jamie





From: Richard Carde 
To: ozDotNet 
Sent: Wed, 20 April, 2011 13:42:59
Subject: Re: add code to all button on my asp.net website?


Anthony

I presume you're trying to disable the button so a user cannot click twice.

This methodology has been discussed previously and, assuming that's the case, 
you're looking at the problem the wrong way around.  This is similar to the 
'how 
do I disable the back button' question.

What do you do if there's a s script error or network glitch during the POST. 
 The user is stuck.

Let the user click as many times as they want or go back and forth - just make 
sure you process the request once.  Do this by inserting a nonce into the form 
as a hidden item and store it in the DB or session state. When you've processed 
it, mark it as such and move the user on - a GUID is often used for this 
purpose.

Job done!  No jiggery-pokery on the client side where you have less control.

Good luck, and do let us know the site you're working on if it goes public.

--
Richard Carde

On 19 Apr 2011, at 03:28, "Anthony"  wrote:


I want add the following to all button on my website  i.e. 
button.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(button, 
"") + ";this.value='Processing Credit Card Payment...';this.disabled = true;")

> 
>Is there an easy to automatically apply this to all buttons?
> 
>regards
>Anthony (*12QWERNB*)
> 
> 

Re: add code to all button on my asp.net website?

2011-04-20 Thread Richard Carde
Anthony

I presume you're trying to disable the button so a user cannot click twice.

This methodology has been discussed previously and, assuming that's the case, 
you're looking at the problem the wrong way around.  This is similar to the 
'how do I disable the back button' question.

What do you do if there's a s script error or network glitch during the POST.  
The user is stuck.

Let the user click as many times as they want or go back and forth - just make 
sure you process the request once.  Do this by inserting a nonce into the form 
as a hidden item and store it in the DB or session state. When you've processed 
it, mark it as such and move the user on - a GUID is often used for this 
purpose.

Job done!  No jiggery-pokery on the client side where you have less control.

Good luck, and do let us know the site you're working on if it goes public.

--
Richard Carde

On 19 Apr 2011, at 03:28, "Anthony"  wrote:

> I want add the following to all button on my website  i.e. 
> button.Attributes.Add("onclick", 
> ClientScript.GetPostBackEventReference(button, "") + ";this.value='Processing 
> Credit Card Payment...';this.disabled = true;")
>  
> 
> Is there an easy to automatically apply this to all buttons?
> 
>  
> 
> regards
> 
> Anthony (*12QWERNB*)
> 
>  
> 
>  


RE: add code to all button on my asp.net website?

2011-04-18 Thread Anthony
Can you suggest how i do this...was hoping to add this to my asp.net code
instead of jquery ..easier tomanage in this instance

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Michael Ridland
Sent: Tuesday, 19 April 2011 2:13 PM
To: ozDotNet
Subject: Re: add code to all button on my asp.net website?

 


I was thinking of using jquery to modify the attribute on the actual html
tag?





On Tue, Apr 19, 2011 at 2:09 PM, Anthony  wrote:

I'm pretty sure jquery will override the event.


-Original Message-
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]

On Behalf Of DotNet Dude
Sent: Tuesday, 19 April 2011 1:46 PM

To: ozDotNet
Subject: Re: add code to all button on my asp.net website?

i don't think it'd be actually overriding the event handler, it is
just appending so should be ok

On Tue, Apr 19, 2011 at 12:56 PM, Anthony  wrote:
> Would this retain any javascript code created by asp.net  eg form
validation
> etc?If i override the onclick event then form validation etc is not
> executed
>
>
>
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of Michael Ridland
> Sent: Tuesday, 19 April 2011 12:38 PM
> To: ozDotNet
> Subject: Re: add code to all button on my asp.net website?
>
>
>
> You could do it with jQuery Very Easily.
>
>
> On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:
>
> I want add the following to all button on my website  i.e.
>
button.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(butt
on, "") + ";this.value='Processing Credit Card Payment...';this.disabled = t
rue;")
>
>
>
> Is there an easy to automatically apply this to all buttons?
>
>
>
> regards
>
> Anthony (*12QWERNB*)
>
>
>
>
>
>



 



Re: add code to all button on my asp.net website?

2011-04-18 Thread Michael Ridland
I was thinking of using jquery to modify the attribute on the actual html
tag?




On Tue, Apr 19, 2011 at 2:09 PM, Anthony  wrote:

> I'm pretty sure jquery will override the event.
>
> -Original Message-
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of DotNet Dude
> Sent: Tuesday, 19 April 2011 1:46 PM
> To: ozDotNet
> Subject: Re: add code to all button on my asp.net website?
>
> i don't think it'd be actually overriding the event handler, it is
> just appending so should be ok
>
> On Tue, Apr 19, 2011 at 12:56 PM, Anthony  wrote:
> > Would this retain any javascript code created by asp.net  eg form
> validation
> > etc?If i override the onclick event then form validation etc is not
> > executed
> >
> >
> >
> > From: ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com]
> > On Behalf Of Michael Ridland
> > Sent: Tuesday, 19 April 2011 12:38 PM
> > To: ozDotNet
> > Subject: Re: add code to all button on my asp.net website?
> >
> >
> >
> > You could do it with jQuery Very Easily.
> >
> >
> > On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:
> >
> > I want add the following to all button on my website  i.e.
> >
>
> button.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(butt
>
> on, "") + ";this.value='Processing Credit Card Payment...';this.disabled = t
> rue;")
> >
> >
> >
> > Is there an easy to automatically apply this to all buttons?
> >
> >
> >
> > regards
> >
> > Anthony (*12QWERNB*)
> >
> >
> >
> >
> >
> >
>
>
>


RE: add code to all button on my asp.net website?

2011-04-18 Thread Anthony
I'm pretty sure jquery will override the event.

-Original Message-
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of DotNet Dude
Sent: Tuesday, 19 April 2011 1:46 PM
To: ozDotNet
Subject: Re: add code to all button on my asp.net website?

i don't think it'd be actually overriding the event handler, it is
just appending so should be ok

On Tue, Apr 19, 2011 at 12:56 PM, Anthony  wrote:
> Would this retain any javascript code created by asp.net  eg form
validation
> etc?    If i override the onclick event then form validation etc is not
> executed
>
>
>
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of Michael Ridland
> Sent: Tuesday, 19 April 2011 12:38 PM
> To: ozDotNet
> Subject: Re: add code to all button on my asp.net website?
>
>
>
> You could do it with jQuery Very Easily.
>
>
> On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:
>
> I want add the following to all button on my website  i.e.
>
button.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(butt
on, "") + ";this.value='Processing Credit Card Payment...';this.disabled = t
rue;")
>
>
>
> Is there an easy to automatically apply this to all buttons?
>
>
>
> regards
>
> Anthony (*12QWERNB*)
>
>
>
>
>
>




Re: add code to all button on my asp.net website?

2011-04-18 Thread DotNet Dude
i don't think it'd be actually overriding the event handler, it is
just appending so should be ok

On Tue, Apr 19, 2011 at 12:56 PM, Anthony  wrote:
> Would this retain any javascript code created by asp.net  eg form validation
> etc?    If i override the onclick event then form validation etc is not
> executed
>
>
>
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of Michael Ridland
> Sent: Tuesday, 19 April 2011 12:38 PM
> To: ozDotNet
> Subject: Re: add code to all button on my asp.net website?
>
>
>
> You could do it with jQuery Very Easily.
>
>
> On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:
>
> I want add the following to all button on my website  i.e.
> button.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(button, "") + ";this.value='Processing Credit Card Payment...';this.disabled = true;")
>
>
>
> Is there an easy to automatically apply this to all buttons?
>
>
>
> regards
>
> Anthony (*12QWERNB*)
>
>
>
>
>
>


RE: add code to all button on my asp.net website?

2011-04-18 Thread Anthony
Would this retain any javascript code created by asp.net  eg form validation
etc?If i override the onclick event then form validation etc is not
executed

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Michael Ridland
Sent: Tuesday, 19 April 2011 12:38 PM
To: ozDotNet
Subject: Re: add code to all button on my asp.net website?

 


You could do it with jQuery Very Easily.




On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:

I want add the following to all button on my website  i.e.
button.Attributes.Add("onclick",
ClientScript.GetPostBackEventReference(button, "") +
";this.value='Processing Credit Card Payment...';this.disabled = true;")

 

Is there an easy to automatically apply this to all buttons?

 

regards

Anthony (*12QWERNB*)

 

 

 



Re: add code to all button on my asp.net website?

2011-04-18 Thread Michael Ridland
You could do it with jQuery Very Easily.



On Tue, Apr 19, 2011 at 12:28 PM, Anthony  wrote:

> I want add the following to all button on my website  i.e. 
> button.Attributes.Add("onclick", 
> ClientScript.GetPostBackEventReference(button, "") + ";this.value='Processing 
> Credit Card Payment...';this.disabled = true;")
>
>
>
> Is there an easy to automatically apply this to all buttons?
>
>
>
> regards
>
> Anthony (*12QWERNB*)
>
>
>
>
>