asp.net mvc 4 - Html.BeginForm in a partial view? -


i have block of code uses html.beginform submit value textbox controller. when put in view, works fine. is, controller's action method called. however, when place block of code inside partial view rendered in view, controller's action never gets called.

not sure if usual behavior or if missing something...

@using (html.beginform("testaction", "home",  formmethod.post, new { id = "formid" })) {<table>    <tr>         <td>data date</td>         <td>@html.textbox("date")</td>     </tr>        <tr>         <td></td>         <td><input id="btnrun" type="submit"  value="submit" /></td>    </tr> 

}

controller:

 [httppost]  public actionresult testaction(string date)  {      [doing something......]      return view();  } 

thanks in advance!

typically @html.beginform() renders <form> tag's action point route details got here. in partial views, you're rendering outer page. (yeah, mind-bending.) if want direct form post particular route, add additional parameters @html.beginform(). see http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.108).aspx


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -