成功解答本帖的朋友可进入下面的相同问题帖回复给分
http://topic.csdn.net/u/20120413/21/8ee7c712-799c-46a0-b069-9305c59e3dee
我的Frameset如下:
<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>
我的树在NavigetionFrame框架中
点击树结点后执行的代码目前是
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
Response.Redirect("TopicList.aspx?Department="+TreeView1.SelectedNode.ValuePath);
}
问题:谁能帮改下代码让我的目标能实现
以下方案我经实验都没效果:
1.在TopicList.aspx文件中如下写
<body><base target="ContentFrame"/>
或<BASE TARGET=\"ContentFrame\">
2.在TopicList.aspx文件中如下写
<form id="form1" runat="server" target = ContentFrame >
3.将树的Target属性设为ContentFrame
网上的只有下面的没搞明白在我的情况下如何改,回为以下的代码是不向网页传参数的情况,不知道如何加,但感觉希望也不大,我的问题倒底出在哪里呢?
Response.Write("<script language=javascript>parent.main.location.href=/"main_right.aspx/";</script>");
------解决方案--------------------------------------------------------
你需要在点击事件跳转页面的同时,指定Target为ContentFrame
你可以新建一个类
- C# code
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); } }}
------解决方案--------------------------------------------------------
别用selectedNodeChanged事件
treeNode.NavigateUrl="TopicList.aspx?Department=1"
treeNode.Target = "ContentFrame"