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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -