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.
<a href="@Url.Action("Index", "Home", new { })">@p</a>
public ActionResult Index(string String)
{
}
@Html.TextBox("String")
You can use
FormMethod.Post
orFormMethod.Get
. The latter will append ?String= to the url.You don't have to use jQuery. If you're doing a
HttpPost
, you just need the "name" of the textbox.On your page:
Then in your controller:
use jquery
then in your script