Monday, 9 September 2013

Value is not getting pass from view to action method

Value is not getting pass from view to action method

i am new in mvc. i have design a form and when i am click the submit
button then right action method is calling but form field's value are not
getting pass.
here is my view code
<div id="mydiv">
@using (Html.BeginForm("Save", "Game", FormMethod.Post, new { @Id =
"Form1" }))
{
<table border="0">
<tr>
<td>Name :</td>
<td><input name="name" type="text" /></td>
</tr>
<tr>
<td>Salary :</td>
<td><input name="salary" type="text" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Save" /> </td>
</tr>
</table>
}
</div>
here is my action method
public ActionResult Save(string str1, string str2)
{
return View("Message");
}
when save is getting called the str1 & str2 is being null please help me
to pass value and also discuss various trick to pass value from view to
action method. thanks

No comments:

Post a Comment