Hasty users often click multiple times on a submit button while the page is trying to connect to the K2.net™ 2003 Server to start a process or complete a K2.net™ client event.

The following code snippet can be inserted in your Page_Load event. It will disable the button immediately after it is clicked. This will give your application time to submit the request and prevent users from clicking the button repeatedly.

BONUS: This code is also applicable for the standard ASP.NET server control button, as the K2Button was inherited from this.

// Set up the Attribute property for the K2 button
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
sb.Append("this.value = 'Busy...';"); // Caption for the button while doing the submit
sb.Append("this.disabled = true;");
sb.Append(this.Page.GetPostBackEventReference(this.K2Button1));
sb.Append(";");

// Add the Attribute property (inject client side code)
this.K2Button1.Attributes.Add("onclick", sb.ToString());