I want to pass the Html.Textbox
value to a controller from anchor tag, so that I can search the value passed to a controller. Please tell me how can I achieve this.
You don't have to use jQuery. If you're doing a HttpPost
, you just need the "name" of the textbox.
On your page:
@using (Html.BeginForm("Index", FormMethod.Post)) {
@Html.TextBox(string.Empty, new { name = "textbox" })
Submit
}
Then in your controller:
[HttpPost]
public ActionResult Index(string textbox) {
// The name of the string parameter must match the name given to the TextBox element on the page.
}