0

我有这个编辑按钮:

 @Ajax.ActionLink(" ", "Edit", new { oid = item.memoOID }, new { id = "edit_" + item.memoOID })

我想从控制器操作“编辑”填充实体并将其发送到下面定义的对话框(我希望它替换新的 Domain.Model.memo() :

<div id="memoAddDialog" title="New Memo" style="display: none">
    @Html.Partial("~/Views/Pat/newMemoDialog.cshtml", new Domain.Model.memo())
</div>

使用此弹出窗口:

function OpenMemoDialog() {
        $("#memoAddDialog").dialog("open");
    }

    $("#memoAddDialog").dialog({
        autoOpen: false,
        height: 575,
        width: 900,
        dialogClass: "positioning24"
    });

我只是不知道如何将值传递给该部分视图并需要一些指针;谁能帮忙?

4

2 回答 2

1

试试这个

  //In View 
    @Ajax.ActionLink("AjaxLink", "Edit", new { oid = item.memoOID ,id = "edit_"+item.memoOID }, new AjaxOptions { UpdateTargetId = "memoAddDialog", HttpMethod = "Post",OnSuccess="Success" })

    <div id="memoAddDialog" title="New Memo" style="display: none">
    </div>

<script type="text/javascript">
function Success()
{
  //open your dialogbox here
   $("#memoAddDialog").dialog("open");
}

</script>

在控制器中

[httpPost]
public ActionResult Edit(string oid , string id)
{
     //perform your functionality 

    return PartialView("~/Views/Patient/newMemoPatientDialog.cshtml", new Mavi.Domain.Model.memo());
}

注意:在 Ajax.ActionLink 中,您必须提供UpdateTargetId,您的结果将出现在页面上

于 2012-09-28T08:50:51.970 回答
0

我会做这样的事情:

<a href="OpenMemoDialog('@(Url.Action("Edit", new oid = item.memoOID)')" />

与 OpenMemoDialog 为:

function OpenMemoDialog(url) {
        $("#memoAddDialog").dialog("open");
        $("#memoAddDialog").load(url);
    }

memoAddDialog 只是一个空的 div 并且您的 Edit 操作应该返回部分视图。

于 2012-09-28T08:20:29.713 回答