[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.NET 2.0 Button One Click

Posted on 2006-05-15
4
Medium Priority
?
1,204 Views
Last Modified: 2008-06-02
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
Comment
Question by:jj819430
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
nehaya earned 1000 total points
ID: 16688142
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
 
LVL 7

Author Comment

by:jj819430
ID: 16691390
this still gives the same issue.... the button doesn't post back once.
0
 
LVL 7

Author Comment

by:jj819430
ID: 16694112
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
 

Expert Comment

by:mattphung
ID: 21692643
ii819430-

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question