我有以下网址:传递URL参数和表单数据一起
http://localhost:49970/Messages/Index/9999
而在视图“索引”我有一个表格,我发布表单数据的动作指数(除芯与[HttpPost ])使用jQuery,像这样:
检视:
<script type="text/javascript">
function getMessages() {
var URL = "Index";
$.post(
URL,
$("form").serialize(),
function(data) {
$('#tabela').html(data);
}
);
}
</script>
<% using (Html.BeginForm()) {%>
<%=Html.TextArea("Message") %>
<input type="button" id="submit" value="Send" onclick="javascript:getMessages();" />
<% } %>
控制器:
[HttpPost]
public ActionResult Index(FormCollection collection)
{
//do something...
return PartialView("SomePartialView", someModel);
}
我的问题:如何在操作索引中获取参数“9999”和窗体FormCollection?
PS:对不起我的英语:)
感谢您的快速答复门迪:) 其实,我的参数是一个GUID(像 “08254a2a-7089-46e6-B03D-406a72a34148”)。我尝试像你说要声明的方法: 公众的ActionResult指数(GUID ID,字符串消息?) {// id为null //消息是确定的(有我输入值) 回报PartialView( “SomePartialView”,someModel); } 如果我更改可空的Guid?只有Guid,当我按下按钮什么都没有发生...... – Fabio 2010-04-07 02:59:10