Wednesday, June 16, 2010

Watermark TextBox using JavaScript

http://www.asp.net/ajaxlibrary/act_TextBoxWatermark.ashx



http://www.aspsnippets.com/Articles/Watermark-TextBox-using-JavaScript.aspx

Preventing Multiple Form Submits using javascript

source: http://www.elated.com/articles/preventing-multiple-form-submits/

write the below javascript code
var form_submitted = false;

function submit_form ( )
{
if ( form_submitted )
{
alert ( "Your form has already been submitted. Please wait..." );
return false;
}
else
{
form_submitted = true;
return true;
}
}



write the below function cal in html form

form onsubmit="return submit_form()"

Button that prevents multiple clicks in asp.net

Button that prevents multiple clicks

Here's the solution (in code behind):


private void BuildClickOnceButton(WebControl ctl)
{

System.Text.StringBuilder sbValid = new System.Text.StringBuilder();

sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");

sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");

sbValid.Append(ctl.ClientID + ".value = 'Please wait...';");

sbValid.Append(ctl.ClientID + ".disabled = true;");

//GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.

sbValid.Append(ClientScript.GetPostBackEventReference(ctl, ""));

sbValid.Append(";");

ctl.Attributes.Add("onclick", sbValid.ToString());

}