Sharepoint 2010: Open Modal Dialog from EditControlBlock
// June 9th, 2010 // Uncategorized
Visual Studio 2010 makes it really easy to create and upload Features. Using these new Features makes it easy to add actions to menus. One of these menus is the Edit Control Block (ECB) or the context menu which appears over an item:

Normally we’d use a simple UrlAction and fill the Url with the redirect. However in this case to call the modal, we can do the following:
| XML | | copy code | | ? |
| 01 | <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> |
| 02 | <CustomAction Id="ReportConcern" RegistrationType="ContentType" RegistrationId="0x0101009b56d20860764b8090e63b320d78f98c" Location="EditControlBlock" Sequence="107" Title="Report Concern" Description="To report a concern on this item"> |
| 03 | <UrlAction Url="javascript: |
| 04 | function CallDETCustomDialog(dialogResult, returnValue) |
| 05 | { |
| 06 | SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK); |
| 07 | } |
| 08 | var options = { |
| 09 | url: '{SiteUrl}' + '/_layouts/ReportConcern/ReportConcern.aspx?List={ListId}&ID={ItemId}', |
| 10 | title: 'Report Concern', |
| 11 | allowMaximize: false, |
| 12 | showClose: true, |
| 13 | width: 500, |
| 14 | height: 300, |
| 15 | dialogReturnValueCallback: CallDETCustomDialog }; |
| 16 | SP.UI.ModalDialog.showModalDialog(options);" /> |
| 17 | </CustomAction> |
| 18 | </Elements> |









Nice.
What changes would I have to make if I want my a particular Display View from the ‘template.xsn’ to appear in a ‘Modal Dialog”?
The New, Edit & Display modal dialog’s are woking fine … but I’ll be damned if I can get one of my custom context menu items from a SharePoint list to appear in a Dialog box. Getting them to appear the ‘flat’ page is easy ..
Any suggestions?
Chris.
Have a look a good explanation of Model dialog…
http://www.a2zmenu.com/SharePoint/SharePoint%202010%20Model%20Dialog.aspx
A better way to embed JavaScript instead in the UrlAction
Referencing Javascript Files with SharePoint 2010 Custom Actions using SciptSrc
http://weblogs.asp.net/jan/archive/2010/03/01/scriptsrc-referencing-javascript-files-with-sharepoint-2010-custom-actions.aspx