MVC 3局部视图弹出问题

时间:2011-05-04 16:32:48

标签: asp.net-mvc-3 popup

我一直在尝试创建一个弹出窗口,其中一些细节从部分视图中收集,但我无法做到。

我已经按照这个例子,这很清楚,但对我不起作用。 MVC-pop up windows

我添加了我的代码,也许有人可以看到比我好,为什么不工作。

提前致谢,Pablo。

这是控制器

    [HttpGet]
    [Authorize]
    public ActionResult _CustomerDetails(int idAddress)
    {
        using (CustomerAddressClient client = new CustomerAddressClient())
        {

            var address = client.CustomerAddress_Read(idAddress);

            ViewBag.CustomerAddress = address;
        }
        return PartialView();
    }

然后我有了这段代码的视图

@Ajax.ActionLink("Open popup", "_CustomerDetails", new AjaxOptions { HttpMethod = "GET",       UpdateTargetId = "customerdetails2", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })

<div id="customerdetails2" ></div>

$(document).ready(function () {
    $("#customerdetails2").dialog({
        autoOpen: false,
        title: 'Title',
        width: 500,
        height: 'auto',
        modal: true
    });
});

function openPopup() {
    $("#customerdetails2").dialog("open");
}    

,部分视图只是客户详细信息的列表

<table style="width: 100%;" class="customerTable">
    <tr>
        <td>Address1</td> <td>@ViewBag.CustomerAddress.idAddress</td>
    </tr>
    <tr>
        <td>Address2</td><td>@ViewBag.CustomerAddress.Address2</td>
    </tr>
    <tr>
        <td>Address3</td><td>@ViewBag.CustomerAddress.Address3</td>
    </tr>
    <tr>
        <td>City</td><td>@ViewBag.CustomerAddress.City</td>
    </tr>
    <tr>
        <td>CompanyName</td><td>@ViewBag.CustomerAddress.CompanyName</td>
    </tr>
</Table>

好吧,页面继续显示在同一个容器中,它不会显示弹出窗口。

0 个答案:

没有答案