Chcę uzyskać wartość pola tekstowego HTML w kontrolerze. Poniżej jest mój kod widokUzyskaj wartość kontrolek HTML w kontrolerze
@using (Html.BeginForm("SaveValues", "TestGrid",FormMethod.Post))
{
<table>
<tr>
<td>Customer Name</td>
<td>
<input id="txtClientName" type="text" />
</td>
<td>Address</td>
<td>
<input id="txtAddress" type="text" /></td>
<td>
<input id="btnSubmit" type="submit" value="Submit" /></td>
</tr>
</table>}
proszę sprawdzić mój kod kontrolera poniżej w celu uzyskania wartości
[HttpPost]
public ActionResult SaveValues(FormCollection collection)
{
string name = collection.Get("txtClientName");
string address = collection.Get("txtAddress");
return View();
}
otrzymuję wartości null
uratowałeś mi życie)) –