a little problem for ya.
in master page i have a search input and link:
<input type="text" value="Searche..." name="txtSearche" id="txtSearche" style="vertical-align: middle; height:14px;" />
<%= Html.ActionLink("search", "Search", "Search", new{ searche = "txtSearche???what is here"}, null) %>
how can i write value in url “value” from input text and then get it in my search controller?
[HttpGet]
public ActionResult Search(string txtSearche)
{
try
{
SearchModel model = new SearchModel(txtSearche);
if (txtSearche != null)
{
return View(model);
}
else
{
return View();
}
}
my biggest problem is here-> new{ searche = “txtSearche???what is here”}
i dont know how to make this part working
simple 🙂 just put it in the parameters.
or you also can do
string searche = Request["searche"]but in MVC, use the first option 🙂Edit: ok i get what you want. you have an input form and you want to use this.
2 words: USE POST.
you are trying to make a get request in the URL what is actually a POST request. make a post, and then in your returning view, you can make the query come up in the URL as well.
the best thing is, make the postback, which will return navigate to the new URL with your searchquery in it with this