I have a search bar on my Home-Index page:
<p>
Find by name: @Html.TextBox("SearchString")
<input type="submit" value="Search" />
</p>
I need to submit this string into my code controller and take the user to the Code-Index page using the code controller, rather than the home controller. It seems the parameter is not enough for it to pick it up:
public ViewResult Index(string sortOrder, string searchString)
{
}
How would I go about this?
Wrap it in a form and specify the controller and the action you want to submit to:
@using (Html.BeginForm("Index", "SomeOtherControllerName"))
{
<p>
Find by name: @Html.TextBox("SearchString")
<input type="submit" value="Search" />
</p>
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With