在页面左边有个TreeView控件,如何实现单击TreeView得节点,页面右边得内容随之变换,TreeView的节点是从XML中读出来的,我想点击TreeView的节点,右边的页面替换为新的***.aspx,内容也随之改变,但为什么我要点两次以后才实现右边的页面替换,而且只是第一次点时要点两次,以后点一次就可实现页面替换,小弟初学找不出原因请各位高手指点下,我在这里非常的感谢!谢谢!
解决方案 »
- 在VS中使用SVN时遇到的问题
- asp.net 网站发布后出现“未将对象引用设置到对象的实例”错误
- 为什么.aspx 小数转换整型会提示字符串格式不正确
- [求助]邮件发送问题
- 如何实现MD5加密(vb+ACCESS)
- repeater中radiobuttonlist如何绑定数据?
- flashlove2008近来!!我送你分
- 如果把System.Drawing.Image赋值给html的img标签?
- asp.net+sql-server 严重空难,快急死了
- 问题1、在Namespace外的using XXX和在Namespace内使用using XXX有什么不同啊?问题2、Serialization这是什么东东?
- 说说自己的CSS代码规范吧~!
- 页面输出流 如何如让软件可以下载 高手帮忙啊
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class tree : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
} protected void TreeView1_SelectedNodeChange(object sender, EventArgs e)
{
if (TreeView1.SelectedNode.Value == "钎焊刀具")
{
TreeView1.SelectedNode.NavigateUrl = "bottom.htm";//在前台treeview属性中已设定target
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tree.aspx.cs" Inherits="tree" Debug="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server" >
<div>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1" ImageSet="Arrows" OnSelectedNodeChanged="TreeView1_SelectedNodeChange" ExpandDepth="1" Target="right">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
VerticalPadding="0px" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/ProductMenu.xml">
</asp:XmlDataSource>
<asp:Label ID="Label1" runat="server" Height="37px" Text="Label11111111" Width="100px"></asp:Label>
<asp:Label ID="Label2" runat="server" Height="36px" Text="Label222222" Width="88px"></asp:Label></div>
</form>
</body>
</html>
{
if (TreeView1.SelectedNode.Value == "钎焊刀具")
{
TreeView1.SelectedNode.NavigateUrl = "bottom.htm";应该是这个问题吧,触发SelectedNodeChange事件后,SelectedNode的url被改变,但此时并未跳转,再点击时才会跳到这个URL
还要这么麻烦在事件中赋值
document.getElementById("frameid").src=要跳转的url;
就给NavigateUrl属性赋对应的url值
target为你要跳转的frame的id值
foreach (DataRowView drv in dv)
{
TreeNode tn = new TreeNode();
// 设置树的节点Text值和value值
tn.Text = "aaa";
tn.Value = "aaa.aspx";
tn.NavigateUrl = tn.Value;
tn.Target = "FrmMain";
tn.SelectAction = TreeNodeSelectAction.SelectExpand;
}
this.tvTree.Nodes.Add(tn);这个从数据库查询出数据,然后遍历,把值赋给treenode上,点击就自动跳转
例子很简单,能明白就可以了
不知道是不是楼主所要
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>document.getElementById("frameid").src=要跳转的url;</script>", true);
if (TreedNode.Value == "钎焊刀具")
{
TreeNode.NavigateUrl = "bottom.htm";
}
{
Response.Redirect("bottom.htm");
}
例如TreeNode node=new TreeNode();
node.Value="Google";
node.Text="<a href='http://www.google.cn'>Google</a>"
这样不可以吗。。
非要在SelectedNodeChange中判断赋值吗?
还是数据库设计问题?