none
Modal Dialog RRS feed

  • Question

  • Hi..

    On sample Page load we are showing modal popup dialog using SP.UI.ModalDialog.showModalDialog. But in modal popup page we are having  2 btns agree and disagree. when we click any one we need to redirect to another page but its redirecting with  modal dialog screen, so how to remove modal dialog screen (i.,e full page when we redirect from btn click)


    Tagore


    • Edited by Tagore 534 Sunday, January 4, 2015 5:40 PM
    Sunday, January 4, 2015 5:39 PM

Answers

  • Please refer - Redirection to another page from SP.UI.ModalDialog
    Problem

    Redirecting to another page from the SP.UI.ModalDialog Modal window without closing the window will not work and it always opens a new modeless window where the page will be displayed. The dialog framework supports the Source=url querystring variable like the rest of SharePoint. But this has to be part of the Dialog Options to redirect to another page. However, if you have a requirement to dynamically get the page which needs to be redirected from the dialog then this may create a problem...

    Solution
    The solution for the problem would be to create an intermediate html page. This would have a <frameset> html element with a single frame and set the src attribute with the page which you actually need to load inside the Modal Dialog. So now if the user clicks the link which navigates to another page, it will be opened within the same dialog window instead of a new window. Here's how it works...

    more links- http://sharepoint.stackexchange.com/questions/93386/sharepoint-2010-modal-box-with-multiple-button-redirects


    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

    Sunday, January 4, 2015 5:58 PM
  • You can redirect quite easily, if you can use callback function. So instead of redirecting from dialog itself, you need to have a callback function. On Agree or disagree button click, you need to close the dialog with passing a parameter (say 1 for agree, 2 for disagree) and then in the parent window, based on the button clicked you can redirect. So the whole idea is don't redirect in dialog, rather close the dialog and then redirect from parent window. SharePoint Modal dialog has the callback option already built in.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    Monday, January 5, 2015 4:10 AM
  • try these links:

    http://stackoverflow.com/questions/11222921/redirect-from-modal-box-to-non-modal-page

    http://www.ashokraja.me/articles/How-to-redirect-reload-or-refresh-a-page-after-closing-the-SharePoint-2013-Modal-Popup-Dialog

    http://sharepoint.stackexchange.com/questions/41128/close-modal-dialog-and-redirect-to-previous-page-with-parameter

    http://www.mssharepointtips.com/tip.asp?id=1094


    http://sharepoint.stackexchange.com/questions/40827/open-a-different-page-within-a-modal-dialog
    Monday, January 5, 2015 9:54 AM
  • Hi,

    We can use dialogReturnValueCallback and parent.window.location.href to achieve your requirement.

    The following code for your reference:

    <script type="text/javascript">    
         function openDialogWithCallBack(tUrl, tTitle) {
             var options = {
                 url: tUrl,
                 title: tTitle,
                 dialogReturnValueCallback: onPopUpCloseCallBack
             };
             SP.UI.ModalDialog.showModalDialog(options);
         }
      
         function onPopUpCloseCallBack(result, returnValue) {
             if(result== SP.UI.DialogResult.OK){
                parent.window.location.href="http://redirectURL";
    
             }else if(result== SP.UI.DialogResult.cancel){
                parent.window.location.href="http://redirectURL";
             }
         }
    </script>
    Best Regards


    Dennis Guo
    TechNet Community Support


    Wednesday, January 7, 2015 2:21 AM
    Moderator

All replies

  • Please refer - Redirection to another page from SP.UI.ModalDialog
    Problem

    Redirecting to another page from the SP.UI.ModalDialog Modal window without closing the window will not work and it always opens a new modeless window where the page will be displayed. The dialog framework supports the Source=url querystring variable like the rest of SharePoint. But this has to be part of the Dialog Options to redirect to another page. However, if you have a requirement to dynamically get the page which needs to be redirected from the dialog then this may create a problem...

    Solution
    The solution for the problem would be to create an intermediate html page. This would have a <frameset> html element with a single frame and set the src attribute with the page which you actually need to load inside the Modal Dialog. So now if the user clicks the link which navigates to another page, it will be opened within the same dialog window instead of a new window. Here's how it works...

    more links- http://sharepoint.stackexchange.com/questions/93386/sharepoint-2010-modal-box-with-multiple-button-redirects


    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

    Sunday, January 4, 2015 5:58 PM
  • You can redirect quite easily, if you can use callback function. So instead of redirecting from dialog itself, you need to have a callback function. On Agree or disagree button click, you need to close the dialog with passing a parameter (say 1 for agree, 2 for disagree) and then in the parent window, based on the button clicked you can redirect. So the whole idea is don't redirect in dialog, rather close the dialog and then redirect from parent window. SharePoint Modal dialog has the callback option already built in.


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

    Monday, January 5, 2015 4:10 AM
  • try these links:

    http://stackoverflow.com/questions/11222921/redirect-from-modal-box-to-non-modal-page

    http://www.ashokraja.me/articles/How-to-redirect-reload-or-refresh-a-page-after-closing-the-SharePoint-2013-Modal-Popup-Dialog

    http://sharepoint.stackexchange.com/questions/41128/close-modal-dialog-and-redirect-to-previous-page-with-parameter

    http://www.mssharepointtips.com/tip.asp?id=1094


    http://sharepoint.stackexchange.com/questions/40827/open-a-different-page-within-a-modal-dialog
    Monday, January 5, 2015 9:54 AM
  • Hi,

    We can use dialogReturnValueCallback and parent.window.location.href to achieve your requirement.

    The following code for your reference:

    <script type="text/javascript">    
         function openDialogWithCallBack(tUrl, tTitle) {
             var options = {
                 url: tUrl,
                 title: tTitle,
                 dialogReturnValueCallback: onPopUpCloseCallBack
             };
             SP.UI.ModalDialog.showModalDialog(options);
         }
      
         function onPopUpCloseCallBack(result, returnValue) {
             if(result== SP.UI.DialogResult.OK){
                parent.window.location.href="http://redirectURL";
    
             }else if(result== SP.UI.DialogResult.cancel){
                parent.window.location.href="http://redirectURL";
             }
         }
    </script>
    Best Regards


    Dennis Guo
    TechNet Community Support


    Wednesday, January 7, 2015 2:21 AM
    Moderator