我有一个ASP.NET MVC 4应用程序.我的应用程序中有一个剃刀视图,它使用List类型作为模型.
@model List<MeetingLog.Models.UserModel>
@{
Layout = null;
}
.
.
.
我正在迭代模型变量,如下所示:
@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",type = "participant"},null)
</td>
</tr>
}
我需要将两个变量传递给具有操作链接的SavePerson操作.第一个是当前的UserModel,第二个是名为type的字符串变量.但在我的行动中,第一个参数是null.但字符串参数正确.我怎样才能做到这一点?
解决方法
我使用ajax调用
$('.btnSave').on('click',function(){
$.ajax({
url: '@(Url.Action("SavePerson","Meeting"))',type: 'post',data: {
Value1: 'Value1',Value2: 'Value2'
},success: function (result) {
alert('Save Successful');
}
});
});
如果你想用href =#希望这有帮助,可以点击按钮或点击链接.
