0

I have a search field and button on my master page. When a user types in a search term, and hits submit, I would like the search results to display in a content page.

What would be the best, most logical way of handling this?

I thought of using FindControl on my content page to find the button, and then somehow figure out if it had been clicked or not...but my logic quickly spiraled downhill.

Any thoughts?

Thanks!

SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185

3 Answers3

1

Maybe the easiest way to handle this is to use the form as a get not a post. If you have issues with that because you are using a postback event. You could redirect back to the same location with your querystring having the search criteria in the URL. Then you just need to read the search criteria from the URL using Request("[SearchVariable]").

user1390125
  • 51
  • 1
  • 3
1

I handle this in a really simple way:

When the button is clicked I simply set the information I want to search for into a session variable and then redirect the page to my search page, which takes that value

         protected void btnSearch_OnClick(object sender, EventArgs e)
    {
            Session["General"] = txtSearch.Text;
            Response.Redirect("\\Search.aspx");
    }
Limey
  • 2,642
  • 6
  • 37
  • 62
1

The easiest way (probably not the best) would probably be to redirect to your results page and put the search term in the query string. Then when you arrive on the results page check the query string and do the search on the content page.

There is also another post here That I have just found found after quick search but I am not sure if this is a good way either

I would be intrigued to know what way you do finally do this.

Community
  • 1
  • 1
Bex
  • 4,898
  • 11
  • 50
  • 87