I am creating a website wherein I am displaying a gridview and below it I have a button upon whose click I want to hide all the buttons on the web page till the processing completes. I have tried through code behind and its hiding it after the OnClick function completes its execution but what I want is to disable the input for the time in which the OnClick function is executing only.
Below is my piece of code,
protected void Button2_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
b.Enabled = false;
// processing goes here
}
and my button is as follows:
<asp:Button ID="Button2" runat="server" CssClass="SyncButton1"
Text="Sync With AMS"
CausesValidation="true" OnClientClick="ShowProgress()"
OnClick="Button2_Click"
Visible="false" />
Below is my piece of JS,
function ShowProgress() {
$("#form1 :input").prop('readonly', true);
var modal = $('<div />');
modal.addClass("modal");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
loading.css({ top: top, left: left });
}
I am still able to click on the buttons which should not happen for the while when my OnClick function is executing.
Can anyone suggest some other way?