We can generate the same form using HTML Helpers as follows (HTML.BeginForm, @Html.Label, and @Html.TextBox generate the HTML form, label, and textbox elements, respectively):
@using (Html.BeginForm()){ <table> <tr> <td>@Html.Label("Name")</td> <td>@Html.TextBox("txtName")</td> </tr> <tr> <td>@Html.Label("Age")</td> <td>@Html.TextBox("txtAge")</td> </tr> <tr> <td colspan="2"><input type="submit" value="Submit"> </td> </tr> </table>}
The following screenshot gives a glimpse of the task of HTML Helpers:
You might wonder why we need to use HTML ...