In this article I will explain with an example, how to pass (send) TextBox value from View to Controller without Model in ASP.Net MVC Razor.
This article will illustrate how to send TextBox values using Form Collection in ASP.Net MVC Razor.
The Controller consists of two Action methods.
Action method for handling GET operation
Inside this Action method, simply the View is returned.
Action method for handling POST operation
Inside this Action method, the values of both the TextBoxes are fetched using the Form Collection i.e. Request.Form collection using their Name attribute values.
public class HomeController : Controller
// GET: Home
public ActionResult Index()
public ActionResult Index(FormCollection form)
string name = form["Name"];
string country = form["Country"];
The View consists of an HTML Form which has been created using the Html.BeginForm method with the following parameters.
ActionName – Name of the Action. In this case the name is Index.
ControllerName – Name of the Controller. In this case the name is Home.
FormMethod – It specifies the Form Method i.e. GET or POST. In this case it will be set to POST.
There are two TextBoxes. The TextBox for the Name value is a simple HTML INPUT element while the TextBox for the Country value is created using Html.TextBox helper function.
There’s also a Submit Button at the end of the Form and when the Button is clicked, the Form is submitted.
Layout = null;
<meta name="viewport" content="width=device-width"/>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
<td><input type="text" name="Name"/></td>
<input type="submit" value="Submit"/>
Form with two TextBox fields
TextBox Values read from Form Collection