Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's pretty easy - you create a partialview that will be the actual dialog content (let's call it MyDialogPV) - you create a method in the controller that returns the PartialView (GetMyDialogPV) - you use ajax to call the PartialView and render it at runtime as a dialog (in the example I use the JqueryUI plugin).</p> <p>Controller code:</p> <pre><code>public PartialViewResult GetMyDialogPV() { //do some stuff, probably you'll need to set up a model given input parameters ViewBag.Text = "This is my dialog text, opened at " + DateTime.Now.ToLongTimeString(); //retunr the partialview rendered return PartialView("MyDialogPV"); } </code></pre> <p>The partial view for the dialog:</p> <pre><code>&lt;div&gt;Title&lt;/div&gt; &lt;div&gt; @ViewBag.Text &lt;/div&gt; </code></pre> <p>The parent page code:</p> <pre><code>@{ViewBag.Title = "Home Page";} &lt;script&gt; $(document).ready(function () { $('#lod').click(function () { //click event of the link //load the dialog via ajax $.ajax({ url: '@(Url.Action("GetMyDialogPV"))', type: "GET", dataType: "html", cache: false, success: function (data) { $('#myDialogContainer').html(data); //write the dialog content into the diaog container $("#myDialogContainer").dialog({ //dialogize it with JqueryUI autoOpen: false, height: 400, width: 450, modal: true, buttons: { "Chiudi": function () { $(this).dialog("close"); } }, close: function () { } }); $("#myDialogContainer").dialog("open"); //open it! }, error: function (xhr, ajaxOptions, thrownError) { alert('Error'); } }); }); }); &lt;/script&gt; &lt;a id="lod"&gt;Load And Open Dialog&lt;/a&gt; &lt;div id='myDialogContainer' style="background:red"&gt;this is the container for the html retrieved by the controller action GetMyDialogPV&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload