我在一个网站上工作,该网站必须发布到第三方网站才能在客户的网站上进行搜索。我最终做了一个简单的 Response.Redirect 并通过查询字符串传递了搜索参数,如下所示:
protected void Button1_Click(object sender, EventArgs e)
{
string SearchQueryStringParameters = @"?SearchParameters=";
string SearchURL = "Search.aspx" + SearchQueryStringParameters;
Response.Redirect(SearchURL);
}
在您的页面加载中的 Search.aspx 页面上...
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["SearchParameters"]))
{
// prefill your search textbox
this.txtSearch.Text = Request.QueryString["SearchParameters"];
// run your code that does a search and fill your repeater/datagrid/whatever here
}
else
{
// do nothing but show the search page
}
}
希望这可以帮助。