FormMethod.Get and query string parameters

Posted by parminder on Stack Overflow See other posts from Stack Overflow or by parminder
Published on 2010-05-28T03:25:04Z Indexed on 2010/05/28 3:31 UTC
Read the original article Hit count: 349

Filed under:
|
|

Hi Experts,

I am working on a website in asp.net mvc. I have to show a view where user put some search values like tags and titles to search. I want to use the same Index method for that. I have make my form to use formMethod.Get to send the parameters as querystring.

so here is the method

    [HttpGet]
    public ActionResult Index(string title, string tags, int? page)
    {
        if (string.IsNullOrEmpty(title)
           return View(null);

        var list = GetSomeData();

         return View(list);

    } 

here is my view

<div id="searchBox">
                <% using (Html.BeginForm(null, null, FormMethod.Get))
                   { %>
                <table>
                    <tr>
                        <td>
                            <input type="hidden" id="isPosted" name="isPosted" value="1" />
                                I am looking for
                                <%=Html.TextBox("Title")%>
                                Tags:
                                <%=Html.TextBox("Tags")%>
                                <input id="search" type="submit" value="Search" />
                            </td>
                    </tr>
                </table>
                <% } %>

So when the user first visit the page, he will see only two text boxs and a button. but when he types something in the title and tags and click the search button i will load the view with some data.

Now the problem is when i type something in title and tags box and click search, they are received in the method, but are not visible in the url. Is there anything i m doing wrong.

help will be appreciated.

Regards

Parminder

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET