62,268
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
/// <summary>
///ResponseHelper 的摘要说明
/// </summary>
public static class ResponseHelper
{
public static void Redirect(string url, string target, string windowFeatures)
{
HttpContext context = HttpContext.Current;
if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures))
{
context.Response.Redirect(url);
}
else
{
Page page = (Page)context.Handler;
if (page == null)
{
throw new InvalidOperationException("Cannot redirect to new window outside Page context.");
}
url = page.ResolveClientUrl(url);
string script;
if (!String.IsNullOrEmpty(windowFeatures))
{
script = @"<script>window.open(""{0}"", ""{1}"", ""{2}"");</script>";
}
else
{
script = @"<script>window.open(""{0}"", ""{1}"");</script>";
}
script = String.Format(script, url, target, windowFeatures);
page.RegisterStartupScript("", script);
}
}
}
<html>
<frameset id="sidebar_content" cols="225, *" frameborder="1" border="6" framespacing="5" bordercolor="#A1C7F9">
<frame name="NavigetionFrame" src="tree.aspx" frameborder="1" />
<frame name="ContentFrame" src="TopicList.aspx"/>
</frameset>
</html>
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
string url = "TopicList.aspx?Department="+TreeView1.SelectedNode.ValuePath;
ResponseHelper.Redirect(url,"ContentFrame", "");
}