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();
}
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s