Detailed steps to create a custom modal dialog page and show it when a ribbon button is clicked in a document library.
User Case -
1. User clicks on Ribbion button “About” in the document library.
2. About button the displays the custom dialog page and passes the current library name.
3. The dialog page then parses the url parameter, Library name in our case and display the description field as text in the dialog page.
Results -
Ribbon Button
About Dialog -
Steps –
1. Create a empty project “custommodaldialog”.
2. Deploy it as a Farm solution.
3. Right click on the feature and click “Add feature”.
4. Next right click on project and add a new item and select an application page “MyCustomDialogPage.aspx”. This will be out cutsom dialog page.
5. Open the MyCustomDialogPage.aspx page and add a lablel “AboutText” in PlaceHolderMain.
6. Next, write the below code in the applictaion page to display the About text for a library.
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace CustomModalDialog.Layouts.CustomModalDialog
{
public partial class MyCustomDialogPage : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
SPWeb web = SPContext.Current.Web;
if (Request.QueryString["sourcelibrary"] != null)
{
String CurrentListName = Request.QueryString["sourcelibrary"].ToString();
SPList _currentList = web.Lists[CurrentListName];
AboutText.Text = string.Format(“
About This Library
{0}”,_currentList.Description);
}
}
}
}
You Project should look like -
7. Next we will create an empty element to display our custom ribbon button “About” which when clicked will open up
our above created custom dialog page. See Part 2 >>








