• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1208
  • Last Modified:

ASP.NET 2.0 Button One Click

Ok, so this was an issue in 1.1 but I could always do a work around using this.Page.GetPostBackEventReference(this) to force the post and some javascript. Now with 2.0 I can't seem to get it to work. Anyone got a good solution for 2.0 that allows a button/image button to be clicked only once?
You can't set it to disabled=true because then the server side will presume it is disabled. And the data won't be posted correctly.
I can't figure out where the WebForm_DoPostBackWithOptions is done, any ideas on that one as well?
ok, if anyone knows or has the server control that will work for either imagebutton or button for this I appreciate it.
jj
0
jj819430
Asked:
jj819430
  • 2
1 Solution
 
nehayaCommented:
I used to use this approach:

<asp:Button ID="btn" onClick="ServerMethod()" onClientClick="this.enabled=false;" Text="Click Once!" />

for better work, put the enable=false into a javascript function and then you can use it for more..
0
 
jj819430Author Commented:
this still gives the same issue.... the button doesn't post back once.
0
 
jj819430Author Commented:
nvm solved it myself.
Basically created a server control that writes out 2 divs, 1) = the button or image button, 1 = the stuff to show while the backend is processing.
wrap the onclick event of the button/imagebutton with the following javascript code at the pre-render state
if(Page_ClientValidate( TheValidationGroupName )){ myScript; TheOriginalOnClick;}

the I created a small javascript framework that gets called and swaps out the display property of the divs.

Credit for where I started goes to Mike Ellision
http://www.codeproject.com/aspnet/PleaseWaitButton.asp

You will want to re-write a bunch of it but it is a great way to start to solve this problem. Today mike is my hero

But remember to update the system to work in 2.0 correctly and support groupvalidations

0
 
mattphungCommented:
ii819430-

I'm looking for the same functionality for my image button. Can I get a copy of your button? Many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now