I have custom field. This field contains video. In Render method I open modal dialog (SP.UI.ModalDialog), and inside of this dialog I display a video (with WebControls:MediaWebPart). The modal is created with JavaScript:

function loadPlayVideoDialog(){
var options = {
    url: '(...)PlayVideo.aspx',
    autoSize: true,
    showClose: true,
    dialogReturnValueCallback: SP.UI.ModalDialog.RefreshPage};

PlayVideo.aspx is a page in Layouts. It looks like this:

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table cellpadding="4" cellspacing="0" border="0" width="100%" style="margin-left:7px; margin-top:7px;">
            <td id="Td1" name="_invisibleIfEmpty" valign="top" width="100%"> 
                <WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="WebPartZone1" FrameType="TitleBarOnly">
                        <WebControls:MediaWebPart runat="server" ID="MediaWebPart1" PreviewImageSource="/Style Library/Media Player/VideoPreview.png" 
                            Height="340px" Width="420px" AutoPlay="True" ChromeType="None" Loop="False" 
                            Description="Use to embed media clips (video and audio) in a web page." 
                            DisplayMode="Inline" Title="Media Web Part" 
                            __MarkupType="vsattributemarkup" __WebPartId="{99a603f3-3a85-4711-a551-4ed586dbce23}" WebPart="true" __designer:IsClosed="false" partorder="2" />
                        <div style="float:right">
                            <asp:Button Text="Close" runat="server" ID="btClose" OnClientClick="javascript:closeDialog()" />

The problem is, that I cannot close the modal dialog. The 'X' button in the corner doesn't do anything. I even added a button, that calls SP.UI.ModalDialog.showModalDialog.close(); (see the btClose control?). It only reloads the video, but doesn't close the dialog.

Here's a screenshot: http://screencast.com/t/Xm3SlFP7fKG

What did I do wrong? How can I make close work?

  • Out of curiosity, why aren't you using a the overlay player that ships with SharePoint. francois-verbeeck.posterous.com/… Commented Mar 16, 2012 at 16:19
  • That blog post is very good. I will go with this solution - video overlay instead MediaWebpart
    – Tschareck
    Commented Mar 22, 2012 at 9:02

3 Answers 3


Definitely sounds like a JavaScript error as @default noted. Wanted to point out that your callback will not work as you are anticipating. SP.UI.ModalDialog.RefreshPage accepts a value of 1 or 0 for it to refresh the page. Try out my simple mods to your code:

function loadPlayVideoDialog() {
var options = {
    url: '(...)PlayVideo.aspx',
    autoSize: true,
    showClose: true,
    dialogReturnValueCallback: callback

function callback( dialogResult ) {
    SP.UI.ModalDialog.RefreshPage(dialogResult); //will not refresh, form not submitted.


If you open the debug tools and spot an error, feel free to post it.

  • This must be JS issue. At first i thought that because Item is opened in modal, and then I'm creating another modal nested in it, that could be cause. But when I open Item in new tab and then click on link, I'm being redirected to List View.
    – Tschareck
    Commented Mar 18, 2012 at 22:13
  • @Tschareck I've done modals within modals before. It works just fine. You'll want to open up the browser's debugging tools and start the debugger. This may show you or hint at what is happening.
    – iOnline247
    Commented Mar 22, 2012 at 12:42
  • Why did you unmark this as an answer @Tschareck?
    – iOnline247
    Commented Apr 11, 2013 at 15:03

Probably you have a javascript error - please use IE dev toolbar or Firefox Firebug to see if there any error when you click on X.


The most possible reason of that is, that ModalDialog is opened from item form, that itself is also in ModalDialog. When dialog opens another dialog, closing the secfond dialog is not possible.

Related question here: Open SP.UI.ModalDialog within another ModalDialog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.