none
SP.UI.ModalDialog.showModalDialog from a custom action RRS feed

  • Question

  • Hi All,

    I'm attempting to invoke an ASPX page in a modal dialog from a custom action, in this case the personal actions menu.  I've been able to implement the custom action using a simple URL action such as:

    <UrlAction Url="_layouts/HelloWorld.aspx"/>
    

    However when I attempt to call the same page via a modal:

     <CustomAction Id="PersonalActions.HelloWorld"
            GroupId="PersonalActions"
            Location="Microsoft.SharePoint.StandardMenu"
            Sequence="1000"
            Title="HelloWorld">
      <UrlAction Url="javascript: function onClose(){ } 
              var o = { 
                url: '_layouts/HelloWorld.aspx', 
                title: 'HelloWorld', 
                allowMaximize: true, 
                showClose: true, 
                width: 300, 
                height: 200, 
                dialogReturnValueCallback: onClose 
              }; 
              SP.UI.ModalDialog.showModalDialog(o);"/>
     </CustomAction>
    
    

    The modal loads very briefly ( < 1 second ) and then the parent page (not just the contents of the modal) immediately forwards itself to a blank HTML with only the string "[object Object]" displayed.  My initial research indicates that the "[object Object]" string could possibly be related to a type misuse within the javascript but my troubleshooting efforts have hit a wall.  It may also be worth noting that in that brief second when the modal is displayed it appears to be the correct size and contain the desired content so the options are at least paritally accepted.

    Any insights or suggestions would be greatly appreciated.

    - Dan

    Monday, July 12, 2010 3:28 PM

Answers

  • Dan,

    I wrapped this into an anonymous function, and it works for me. Try the following:

    <

     

     

    UrlAction Url="javascript:(function () { var o = { url:'/_layouts/HelloWorld.aspx', title: 'HelloWorld', allowMaximize: true, showClose: true, width: 300, height: 200 }; SP.UI.ModalDialog.showModalDialog(o); }) ();"/>

    Let me know if that works!

    Thanks,

    Dallas

    Monday, July 12, 2010 10:32 PM

All replies

  • Dan,

    I wrapped this into an anonymous function, and it works for me. Try the following:

    <

     

     

    UrlAction Url="javascript:(function () { var o = { url:'/_layouts/HelloWorld.aspx', title: 'HelloWorld', allowMaximize: true, showClose: true, width: 300, height: 200 }; SP.UI.ModalDialog.showModalDialog(o); }) ();"/>

    Let me know if that works!

    Thanks,

    Dallas

    Monday, July 12, 2010 10:32 PM
  • Thanks Dallas,  That did the trick!  Really appreciate the assist on that one.
    Dan B
    Tuesday, July 13, 2010 1:37 PM
  • Hi Dallas,

    It is not working for me. Please help me on same.

    -Thanks,

    Swapnil

    Wednesday, July 13, 2016 11:35 AM