Learning SharePoint   Enhance Your SharePoint Knowledge

Subscribe to Learning SharePoint Subscribe
Twitter Learning SharePointFollow Us
in Learning SharePoint
Check Out Our New SharePoint 2013 series!

Sharepoint 2010 – Create custom modal dialog using Visual studio 2010

06/07/2011  
Category: SharePoint 2010


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 >>

Subscribe to Learning SharePoint Subscribe
Twitter Learning SharePointFollow Us
in Learning SharePoint
Advertisement

Random Posts

Add External users to SharePoint site – SharePoint Online Administration
Add External users to»

Once the SharePoint Online service administrator has set Manage External Users to Allow for a site collection in the SharePoint»

Programatically Send E-mail in Sharepoint 2010
Programatically Send E-mail in»

In this post I will discuss various methods of Sending an e-mail in SharePoint 2010. Method 1 – Code retrieves»

Sharepoint 2010 – Create custom modal dialog using Visual studio 2010 – II
Sharepoint 2010 – Create»

In Continuation with the Part 1 of Sharepoint 2010 – Create custom modal dialog using Visual studio 2010 8. Next»

Recent Forum Posts

Linq to Sharepoint

by RS on May 18, 2012

comments on the code

by spbsmile on May 18, 2012

connection(add) EditControlBlock and my program

by spbsmile on May 18, 2012

Custom master pages used in multiple SharePoint 2010 sites

by ubersteve on May 18, 2012

upload file and click on button but cant upload file into list by using below code

by santhoshreddy on May 18, 2012