请教关于treeview节点点击变色的问题
<Nodes>
<asp:TreeNode Text="首页" Value="首页" NavigateUrl="~/系统首页.aspx"></asp:TreeNode>
<asp:TreeNode Text="用户资源管理" Value="用户资源管理">
<asp:TreeNode Text="用户" Value="用户" NavigateUrl="~/信息中心内容页.aspx"></asp:TreeNode>
<asp:TreeNode Text="组织机构管理" Value="组织机构管理" NavigateUrl="~/组织机构管理中间导航页.aspx"></asp:TreeNode>
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { TreeView1.SelectedNodeStyle.ForeColor = Color.Blue; } A:link { COLOR: #000000; TEXT-DECORATION: none } A:visited { COLOR: #000000; TEXT-DECORATION: none } A:hover { COLOR: #DD5555; TEXT-DECORATION: none } A:active { COLOR: #DD5555; TEXT-DECORATION: none; }<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeView.aspx.cs" Inherits="Galsun.Test.Web.TreeView" %><!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><script> var preNode; function selval(obj, url, target) { //alert(obj.innerHTML); /* var cb = obj.parentNode.parentNode.getElementsByTagName("input"); if (cb.length > 0) cb[0].checked = true; document.getElementById("<%= txt_path.ClientID %>").value = obj.innerHTML; */ if (preNode) preNode.style.color = ""; obj.style.color = "#FF0000"; preNode = obj; //document.getElementById("<%= txt_path.ClientID %>").value = obj; window.open(url, target); }</script><body> <form id="form1" runat="server" > <div> <asp:TextBox ID="txt_path" runat="server" Width="422px"></asp:TextBox> <asp:TreeView ID="TreeView1" runat="server" ImageSet="XPFileExplorer" NodeIndent="15"> <HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" /> <NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="2px" NodeSpacing="0px" VerticalPadding="2px" /> <ParentNodeStyle Font-Bold="False" /> <SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px" VerticalPadding="0px" /> </asp:TreeView> <iframe name="Right" src="http://www.hao123.com" width="600" height="300"></iframe> </div> </form></body></html>
[解决办法]
你都跳转到其他页面了,当然样式、事件都不会保留了,相对于你在A页面点击,这些事件和样式都 在A页面有效,当你转到B页面的时候,B页面是不会保留A页面的样式 的