Content Topcenter
 
Content Left
Resource Centers

\

KB Article

FIX: Security Exception

FIX:IIS metabase Error
Latest Headlines
DotNetNuke Free Skins
DotNetNuke Careers
Microsoft Windows Vista
Microsoft Visual Basic 6.0 Resource Center
Microsoft SQL Server 2005 Released
Visual Studio Beta 2 Released
Code Hut
Preventing multiple clicks
SiteMap with ASP.NET 2
Pop-up window
Java: Activate a button
Disabling right click
Displaying Date & Time
Printing with JavaScript
Using choice control
Starters Corner
What is Booting?
Powering on your PC
Windows Desktop
Need for Recycle Bin
Finding Files & Folders
Usage of My Computer
Need for screensavers
About Virtual Memory
What's new in Win XP?

Preventing multiple click of a submit button
September 26, 2004
by Sameer Lal


If you have certain operations going on, this might result in an error or submission of duplicate or multiple entries. It is a mistake, but should be taken care of in a page, usually where you submit a form.

If your operations are going on in the click event of your button, it is not that possible to disable the button as you cannot do this on server side. It has to be done on client side using Java script.

The On click attribute should be changed with a call to the GetPostBackReference method to call your actual code. All this can be done in just one line of code. It is a very useful when you process some data input forms and this one line of code does the trick. You can do any other process on Button Click event:

Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
\\
Do Whatever
\\
End Sub

Add this line to page load event:

Button1.Attributes.Item("onclick") = "this.disabled=true;" & GetPostBackEventReference(Button1).ToString

Hope you will find it useful.

About the Author

Sameer Lal, from Toronto, Canada, is a Project Mamangement Professional(PMP), Certified Management Accountant (CMA) from USA and Chartered Accountant (CA) from India. Sameer is also Certified Excel 2000 Expert and works as a consultant with one of the leading bank of Canada.
 

Content Right

Learnxpress.com is now listed as a featured site at the Visual C#  developer center of MSDN

Special offer for WordPress lovers

Partners

ASPAlliance.com
Community-Credit.com
Codeguru.com
Csharp-station.com
C-sharpcorner.com
Csharpfaq.com
Csharp-home.com

Dotnetalbum.com
Developer.com

Consulting Services

Web Designing
Web Development
Technical Writing
Online Training

Get Certified

Know about the various Microsoft certifications and how to prepare for the exams {more}


 

411ASP.NET

Content Bottom

Copyright © 2000-2008 Learnxpress.com All rights reserved
Unless otherwise stated all articles posted on this site were authored by Anand Narayanaswamy
[Best viewed with IE6+ and 1024 x 768 resolution]
Privacy Statement | Permissions