Search code examples
asp.net-mvc-3-areas

How to Show modal popup in mvc3?


I need to show details on the popup. I don't have any idea how to do this. I need to do it in a MVC3 Razor view.

my Controller-

public ViewResult ViewDetail(Int32 id)
{
  var q = from p in db.accs
          where p.id == id
          select p;
  return View(q.FirstOrDefault());
}

my View-

<td>@ Html.ActionLink("View Detail", "ViewDetail", new { id=item.id }) </td>

Solution

  • use the Jquery UI ModalForm to show up your data.

    Say you want to display the following in Modal pop-up of jquery .

    <div id="displayinmodal">
    <input type="file" id="file" name="file" />
    <input type="submit" id="submitdata" value="Upload" />
    </div>
    

    Now write your jquery like this.

    <script>
    $(document).ready(function(){
         $("#displayinmodal").dialog({ //displayinmodal is the id of the div you want to display in modal popup
             autoOpen: true
         });
    });
    </script>
    

    That's it. you should get Modal popup in your browser.

    Hope this helps