views:

60

answers:

1

hi, i have a form that have a field which hold query for search and a button to send query value to another action method to perform search. now i want to send this parameter as querystring; not form parameter. but when i click on submit button it's value isn't shown on address bar and sended as form parameter.

<% using (Html.BeginForm("Result", "Search", FormMethod.Post))
       { %>
    <input id="query" name="query" type="text" value="<%: ViewData["InitialQuery"]%>"
        class="search-field" />
    <input id="search" type="submit" value="Search" class="search-button" />
    <%} %>

public ActionResult Result(string query)
    {
        if (string.IsNullOrEmpty(query))
            return RedirectToRoute("SearchEngineBasicSearch");
        var search = new Search();
        var results = search.PerformSearch(query);
        if (results != null && results.Count() > 0)
            return View("Result");
        return View("Not-Found");
    }

URL after clicking on submit button is .../search/result and i want to be .../search/result?query=someQueries

thank in advance ;)

+1  A: 

Change FormMethod.Post to FormMethod.Get.

Caleb
thanks!!!!!!!!!!!
Sadegh