Home > ModalDialog > How to use SharePoint modal dialog box to display Custom Page Part1

How to use SharePoint modal dialog box to display Custom Page Part1

In the part1 of this series, I will show you how to use the modal dialog box to display the custom page and close the page. You can download solution here.

1. Firstly, I create custom action on the list item ECB called Display Custom Page. To do so, you need to create an element item in SharePoint project and copy the following xml to the element file.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="ReportConcern"
Title="Display Custom Page"
Description="To Display Custom Page in a modal dialog box on this item">
<UrlAction Url="javascript:
function CallDETCustomDialog(dialogResult, returnValue)
var options = {
url: '{SiteUrl}' + '/_layouts/YBBEST/TitleRename.aspx?List={ListId}&amp;ID={ItemId}',
title: 'Rename title',
allowMaximize: false,
showClose: true,
width: 500,
height: 300,
dialogReturnValueCallback: CallDETCustomDialog };
SP.UI.ModalDialog.showModalDialog(options);" />

2. In your code behind, you can implement a close dialog function as below. This will close your modal dialog box once the button is clicked.

protected void CloseDialog()
if (HttpContext.Current.Request.QueryString["IsDlg"] == null) return;
if (!ClientScript.IsStartupScriptRegistered("CloseDialogFunction"))
const string script = "<script type='text/javascript'>" + "SP.UI.ModalDialog.commonModalDialogClose(1, 1);" + "</script>";
ClientScript.RegisterStartupScript(GetType(), "CloseDialogFunction", script);

  1. tom
    August 2, 2012 at 9:04 am

    Spent hours looking for this solution. Thanks. Worked perfectly the first time!

  1. June 2, 2012 at 5:44 am

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 )

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: