My problem is as follows:
I am adding a variable to the URL that should trigger a search when the page loads, depending on what is in the variable. If you navigate to that same page without the variable then it shouldn’t do anything special on page load. I figured that the following would do the trick:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.Request.QueryString["cell"] != null)
{
txtCell.Text = Page.Request.QueryString["cell"];
Lookup_Cell(Page.Request.QueryString["cell"]);
//BUGGED, this keeps running when i try a new search
//Page.Request.QueryString["cell"] = null;
}else{
//do nothing, empty string
}
}
This worked like a charm, but i have a search button of the form that is supposed to call the Lookup_Cell method for a cell you specify in a TextBox. i need to make Page.Request.QueryString empty so next time the page loads it won’t fire this special OnLoad. I tried:
Page.Request.QueryString["cell"] = null;
but that didn’t work. I looked for other methods, but can’t find a definite answer.
You can make a simple PostBack check and when there is a post back, get the string from your text box.
Or alternative, when you have post back, redirect to new page with new ‘cell’ query