Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am new to asp.net MVC3. i gave partial view for edit. I want partial view to modal popup instead of displaying in new page. please give me any idea. please provide some example code.

thanks and regards
sreekanth
Posted

1 solution

Here, have a look: load partial view in to a modal popup[^]

Sample, Controller:
C#
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Modal()
    {
        return PartialView();
    }
}

then a Modal.cshtml partial that will contain the partial markup that you want to display in the modal:
HTML
<div>This is the partial view</div>

and an Index.cshtml view containing the button which will show the partial into a modal when clicked:
C#
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('.modal').click(function () {
            $('<div />').appendTo('body').dialog({
                close: function (event, ui) {
                    dialog.remove();
                },
                modal: true
            }).load(this.href, {});

            return false;            
        });
    });
</script>

@Html.ActionLink("show modal", "modal", null, new { @class = "modal" })


Try!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900