Redirect parent of dialog using view in an iframe

Hi,

I have a MVC view that opens a dialog and that dialog opens another view in an iframe.
When I click a button in the view that is in the dialog iframe, how do I 
1. Close the dialog from the iframe view button
2. Redirect the main MVC that opened the dialog

Thanks!

1 Reply

BS Buvana Sathasivam Syncfusion Team October 23, 2017 01:05 PM UTC

Hi Sam, 

Thanks for using Syncfusion Products. 

We have created Dialog sample with iframe.  If you click dialog inside the button, then page was navigate to second dialog.  This second dialog contains iframe by setting contentType property.  You can also go to the main mvc page by creating button on footer of the dialog.  Please find below code. 

DialogFeatures.cshtml 

@{Html.EJ().Dialog("basicDialog").Title("Audi-Q3 Drive" 
     ……… 
     @Html.EJ().Button("button").Text("Click to open dialog iframe").ClientSideEvents(evt => evt.Click("anotherClick"))// First dialog with button 
    ………… 
.Render();} 

<script> 
        function anotherClick() { 
            document.location = '@Url.Action("SecondDialog","Dialog")'// Navigate to second dialog 
        } 
</script> 


SecondDialog.cshtml 
// Second dialog 
@Html.EJ().Dialog("Dialog2").Title("Audi-Q3  Drive").ContentType("iframe").ContentUrl(Url.Action("Contact", "Home")).FooterTemplateId("temp1").ShowFooter(true) 
               
 
<script type="text/template" id="temp1"> 
              @Html.EJ().Button("button").Text("Return to MVC main page").ClientSideEvents(evt => evt.Click("iframeClick"))   
        </script> 
 
<script> 
        function iframeClick(args) { 
            document.location = '@Url.Action("Index","Home")'; // Go to main page 
        } 
        </script> 



Regards, 
Buvana S. 
 


Loader.
Up arrow icon