ASP.NET MVC 4通过ActionLink传递对象变量

Umu*_*ğlu 6 html.actionlink razor asp.net-mvc-4

我有一个ASP.NET MVC 4应用程序.我的应用程序中有一个剃刀视图,它使用List类型作为模型.

@model List<MeetingLog.Models.UserModel>

@{
    Layout = null;
}
.
.
.
Run Code Online (Sandbox Code Playgroud)

我正在迭代模型变量,如下所示:

@foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @item.Name
                        </td>
                        <td>
                            @item.Surname
                        </td>
                        <td>
                            @Html.ActionLink("Click", "SavePerson", "Meeting", new {model = item, type = "coordinator"}, null)
                            @Html.ActionLink("Click", "SavePerson", "Meeting", new {model = item, type = "participant"}, null)
                        </td>
                    </tr>
                }
Run Code Online (Sandbox Code Playgroud)

我需要将两个变量传递给具有操作链接的SavePerson操作.第一个是当前的UserModel,第二个是名为type的字符串变量.但在我的行动中,第一个参数是null.但字符串参数正确.我怎样才能做到这一点?

Mat*_*ily 4

我为此使用 ajax 调用

$('.btnSave').on('click', function(){
    $.ajax({
        url: '@(Url.Action("SavePerson", "Meeting"))',
        type: 'post',
        data: {
            Value1: 'Value1',
            Value2: 'Value2'
        },
        success: function (result) {
            alert('Save Successful');
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

如果需要,可以将调用放入按钮单击或链接单击中,并使用 href = # 希望这会有所帮助。