Disable sumbit button after submit user information in ASP.NET

No.of Views1184
Bookmarked0 times
Downloads 
Votes0
By  Troy   On  15 Feb 2010 23:02:08
Tag : ASP.NET , How to
Disable sumbit button after submit user information in ASP.NET
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction


Here we have to discuss the ie: how to disable the submit button after you submit the detaisl fo example: user are sending some value to database or storing user information so after storing the information i have to disable the submite button to avoid duplicate insertion ie: insert two or more times.

Technologies:

ASP.NET 2.0

Language:

C# and VB.NET


Prerequisite

.NET Framework 2.0,


Visual Studio 2005 or later version


Implementation

For this you have to place one button on your form and write the code

aspx.cs file:


{codecitation class="brush: c#; gutter: true;" width="500px"}

protected void Page_Load(object sender, EventArgs e)
{
string clickHandler = string.Format(
"document.body.style.cursor = 'wait'; this.value='Please wait...'; this.disabled = true; {0};",
this.ClientScript.GetPostBackEventReference(Button1, string.Empty));
Button1.Attributes.Add("onclick", clickHandler);
}

protected void Button1_Click(object sender, EventArgs e)
{
// Emulate a lengthy process of 10 seconds...
TimeSpan waitTime = new TimeSpan(0, 0, 0, 10);
System.Threading.Thread.Sleep(waitTime);

Response.Write("Button1_Click fired
");
}

{/codecitation}



here after send the user information the button will be getting disabled.

Thank you

Venkat


 
Sign Up to vote for this article
 
About Author
 
Troy
Occupation-Not Provided
Company-Not Provided
Member Type-Junior
Location-Not Provided
Joined date-10 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top