asp.net mvc Ajax.BeginForm

Posted by Bala R on Stack Overflow See other posts from Stack Overflow or by Bala R
Published on 2010-04-08T13:11:07Z Indexed on 2010/04/08 13:13 UTC
Read the original article Hit count: 1230

Filed under:
|
|

Hello, I'm having some difficulties with Ajax.BeginForm

I have something like this in a view

  <% using (Ajax.BeginForm("ActionName", null , null, new { id = "FormName" }))
     {%>
      <input type="hidden" value = '<%= Html.Encode( Model.id) %>' name="id"/>
      <textarea id="message" name=message rows="4" style="width: 90%"> 
      </textarea>
  <% }%}

And the action method is something like this

    [AcceptVerbs(HttpVerbs.Post)]
    [Authorize]
    public ActionResult ActionName(int id, string message)
    {
     ....
    }

I'm trying to pass the 'id' and 'message' to the action method. I'm passing 'null' for routeValues but I dont know what to pass. Ideally I was trying to find an overload that did not require route values but took actionName and htmlattributes (for form name) but I could not find one.I don't want to add 'message' to the view-model and I do need the FormName in there for jquery operations. What is the best way to work around this problem ?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc