鉴于您使用的是 ASP.Net,我建议您利用代码隐藏过程的强大功能。除了上述响应之外,您可以做的一个选择是在您的URL 中使用QueryString,因为您可以根据需要进行重定向。
示例 1. 使用 ASP Button
protected void btnOriginalPage_Click(object sender, EventArgs e)
{
string url = "NextPageViewer.aspx?result=" + resultText;
//You can use JavaScript to perform the re-direct
string cmd = "window.open('" + url + "', '_blank', 'height=500,width=900);";
ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindow", cmd, true);
//or you can use this - which ever you choose
Response.Redirect(url);
}
///On the next page - the one you have been redirected to, perform the following
protected void Page_Load(object sender, EventArgs e)
{
//extract the query string and use it as you please
int result = Convert.ToInt32(Request.QueryString["resultText"]);
}
示例 2. 使用 Session 变量并将数据集/结果存储在用户定义的对象或 DTO - 这只是一个包含 setters 和 getters 的类
在 ASP 按钮上执行单击事件,但这次您将执行以下操作:
protected void btnOriginalPage_Click(object sender, EventArgs e)
{
ObjectWithInfo.Result = result;
Session["friendlyName"] = ObjectWithInfo;
Response.Redirect("NextPageViewer.aspx");
}
//On the next page - the one you have been redirected to, perform the following
//The good thing with Session variables is that you can access the session almost anywhere in you application allowing your users to perform the comparison they require.
protected void Page_Load(object sender, EventArgs e)
{
//extract the data from the object to use
int result = ((ObjectWithInfo)(Session["friendlyName"])).Result;
}