469,644 Members | 1,696 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Disable Linkbutton Before Postback?

I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen
Nov 18 '05 #1
6 8835
Hi Al,

I've had that same issue. Usually you have to attach the script code to the
form's OnSubmit().

Actually what I found is that if you disable the button that you're binding
events to the button's event doesn't fire because the button doesn't show up
in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"
onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN
ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it doesn't
animate - some bug in IE related to a hidden image not animating, it works
with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen

Nov 18 '05 #2
A
Hi,
a solution that allways works, even if the user presses F5, or disables
javascript

I normaly insert a database value (ID, Identity) in a hidden form, when the
"updating" or other stuff takes place, it first checks if the value (ID) is
in the database, if it is there updating takes place and the ID is deleted,
if it is NOT there i tell the user that their data is allready saved,
problerly because they hit the submit button twice...

Regards,

Agge

"Rick Strahl [MVP]" <ri********@hotmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Al,

I've had that same issue. Usually you have to attach the script code to the form's OnSubmit().

Actually what I found is that if you disable the button that you're binding events to the button's event doesn't fire because the button doesn't show up in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"
onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it doesn't animate - some bug in IE related to a hidden image not animating, it works
with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen


Nov 18 '05 #3
Yes that is good practice. I think a more general approach should be taken
to this sort of thing, where your code should set something right away that
in teh DB that lets it know that the process has already started.

But I still think from a UI perspective it's smart to use something on the
client side to disable the button.

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"A" <ne**@agge.dk> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
Hi,
a solution that allways works, even if the user presses F5, or disables
javascript

I normaly insert a database value (ID, Identity) in a hidden form, when the "updating" or other stuff takes place, it first checks if the value (ID) is in the database, if it is there updating takes place and the ID is deleted, if it is NOT there i tell the user that their data is allready saved,
problerly because they hit the submit button twice...

Regards,

Agge

"Rick Strahl [MVP]" <ri********@hotmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Al,

I've had that same issue. Usually you have to attach the script code to the
form's OnSubmit().

Actually what I found is that if you disable the button that you're

binding
events to the button's event doesn't fire because the button doesn't show up
in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"

onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it

doesn't
animate - some bug in IE related to a hidden image not animating, it works with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");
which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen



Nov 18 '05 #4
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #5
I dont really understand what you are trying to ask, but as far as I can
guess, you want to disable a link button without postback?
Here is something I did long time ago, I put the linkbutton in a div tag and
used javascript to show and hide it without postback..
Does this suite ur situation?
Hth...
R. Thomas

"Mr.Joe" wrote:
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #6
please elaborate your question. It is very unclear.

"Mr.Joe" <yo***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Bharat | last post: by
3 posts views Thread by Rob Meade | last post: by
10 posts views Thread by Vi | last post: by
13 posts views Thread by rn5a | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.