Passing URL parameter and a form data together

Posted by Fabio on Stack Overflow See other posts from Stack Overflow or by Fabio
Published on 2010-04-07T02:29:59Z Indexed on 2010/04/07 2:33 UTC
Read the original article Hit count: 308

Filed under:
|
|

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 :)

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about asp.net-mvc