SharePoint 2010 Processing or Please Wait Modal Dialog Box

For large time of operation we need to put please wait or process modal dialog box.

We can achieve this functionality from below Javascript and code behind file in Sharepoint

To open popup from client side use javascript and below code :

<script type=”text/javascript”>
function ShowProcessDialogBox() {
myShowWaitScreenWithNoClose(‘Processing..’, ‘Please Wait….’);
return false;
}

function myShowWaitScreenWithNoClose(title, message) {
return SP.UI.ModalDialog.$1I_1(title, message, false, false, null, null, 270, ’12px 12px 4px 6px’, 0);
}
</script>

Once you put above Javascript in code you can call it on button onclientclick event

<asp:Button ID=”btnGenerate” runat=”server” Text=”Generate Button” OnClientClick=”return ShowProcessDialogBox()”
OnClick=”btnGenerate_Click” />

Now to close Modal Box From Code use below Code

private void CloseModalDialogBox()
{
HttpContext context = HttpContext.Current;
if (HttpContext.Current.Request.QueryString[“IsDlg”] != null)
{
context.Response.Write(“window.frameElement.commitPopup();”);
context.Response.Flush();
context.Response.End();
}
}