We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to have a partial view as content of a Dialog?

Thread ID:

Created:

Updated:

Platform:

Replies:

143506 Mar 23,2019 04:25 PM UTC Mar 25,2019 07:25 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Dialog
Juan José
Asked On March 23, 2019 04:25 PM UTC

Hi, 
I want to show some information that I have in a partial view but, I need to show it in a modal window. 
I was wondering if I could use Dialog modal to achieve this.

Kind regards,

Juan J.

Prince Oliver [Syncfusion]
Replied On March 25, 2019 07:25 AM UTC

Hello Juan, 

Greetings from Syncfusion support. 

Yes, you can show the partial view page content in the Dialog component. This can be achieved using the BeforeOpen event in the controls. We have got the partial view page content through AJAX request and placed it in the Dialog component using BeforeOpen event which triggers before opening the dialog. Kindly refer to the following code snippet. 

[Index.cshtml] 
@Html.EJS().Dialog("ajax").Visible(false).BeforeOpen("beforeOpen").IsModal(true).Render() @* Dialog component*@ 
 
<script> 
    function beforeOpen() { // Triggered when before open the dialog component 
        var ajax = new ej.base.Ajax('/Home/PartialView1/?Person2', 'GET', true); 
        ajax.send().then(); 
        ajax.onSuccess = function (data) { // Triggered when ajax post succeeded 
            $("#ajax_dialog-content").html(data) 
        }; 
    } 
</script> 

[PartialView1.cshtml] 
<div id="one"> 
    Parial view page content 
</div> 
@Html.EJS().ScriptManager() @* Please add this code, If you are using any syncfusion component on parital view page content.*@ 


Note: Add ScriptManager at the end of the partial view page when using any Syncfusion controls. 

We have prepared simple modal Dialog component with partial view page content. We have covered the following in the sample, 

  • Open the Dialog component when you click the ‘Open’ button.
  • Got the partial view page content through AJAX post and append into Dialog element when before open the dialog.


For further reference, kindly refer to the following 


Let us know if you need any further assistance on this. 

Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon