0

我想在我的控制器中将模型传递给操作方法,以使用弹出对话框编辑该模型。但是沙化到动作方法的输入参数没有填充数据。

这是我的视图中调用弹出对话框的 HTML 代码:

<span class="label label-border">
      <input class="edit_company" type="button" value="Edit" onclick="getForm()" />
</span>

<div id="dialog"></div>

JavaScript 调用弹出对话框:

<script type="text/javascript">
    function getForm() {
        $('#dialog').dialog({
            autoOpen: true,
            width: 400,
            resizable: false,
            title: 'My Table',
            modal: true,
            open: function(event, ui) {

                $(this).load('@Url.Action("Edit", "Company", Model)');
            },
            buttons: {
                "Close": function() {
                    $(this).dialog("close");
                }
            }
        });
    }
</script>

...这是我从 JavaScript 调用的操作方法,但其中的数据未填充。

在此处输入图像描述

4

1 回答 1

1

请检查您的load命令中的 URL 是什么。只需检查生成的脚本代码。
您最好在 URL 中使用公司 ID:

 $(this).load('@Url.Action("Edit", "Company", new {id=Model.id})');

并在控制器中按 id 加载公司数据

public PartialViewResult Edit(int id)
{
    //code to retrive your company from the database by id
    return PartialView();
}
于 2013-07-16T18:41:33.213 回答