vs2008 asp.net Treeview 如何点击结点将网页载入指定框架

thinclient 2012-04-14 07:32:28
成功解答本帖的朋友可进入下面的相同问题帖回复给分
http://topic.csdn.net/u/20120413/21/8ee7c712-799c-46a0-b069-9305c59e3dee.html

我的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>");
...全文
202 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
thinclient 2012-04-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
别用selectedNodeChanged事件
treeNode.NavigateUrl="TopicList.aspx?Department=1"
treeNode.Target = "ContentFrame"
[/Quote]
你的回复解决了三帖没解决的问题:
请到以下帖中回复加分好么
http://topic.csdn.net/u/20120414/07/19da314a-25e5-4122-8762-816b1d244c7c.html
http://topic.csdn.net/u/20120414/09/2a8c9765-47eb-4b5e-8220-a1e17c860a4e.html
http://topic.csdn.net/u/20120414/11/b25a4b5f-906f-481b-a081-54895a6ae108.html

thinclient 2012-04-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
你需要在点击事件跳转页面的同时,指定Target为ContentFrame

你可以新建一个类

C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

/// <summary>
///Respo……
[/Quote]
谢高手百忙中回复,只是以我现阶段的水平,还用不了你的代码,看不明白,恕不能取用
不过以后必须向你学习
IT-Style 2012-04-14
  • 打赏
  • 举报
回复
别用selectedNodeChanged事件
treeNode.NavigateUrl="TopicList.aspx?Department=1"
treeNode.Target = "ContentFrame"
我爱小土豆 2012-04-14
  • 打赏
  • 举报
回复
vs中用的是iframe吧 frameset 这个在vs中不能用的吧
灵雨飘零 2012-04-14
  • 打赏
  • 举报
回复
指定Target为ContentFrame

暖枫无敌 2012-04-14
  • 打赏
  • 举报
回复
你需要在点击事件跳转页面的同时,指定Target为ContentFrame

你可以新建一个类

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", "");
}

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧