Passing URL parameter and a form data together
- by Fabio
I have following URL:
http://localhost:49970/Messages/Index/9999
And at view "Index" I have a form and I post the form data to the action Index (decored with [HttpPost]) using Jquery, like this:
View:
<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();" />
<% } %>
Controller:
[HttpPost]
public ActionResult Index(FormCollection collection)
{
//do something...
return PartialView("SomePartialView", someModel);
}
My question: How can I get the parameter "9999" and the form FormCollection in the action Index?
PS: Sorry about my english :)