惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
V
V2EX
Jina AI
Jina AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
量子位
L
LangChain Blog
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
腾讯CDC
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss

博客园 - 大白鲨

"Maximum length exceeded"错误的解决办法 - 大白鲨 javascript的数组使用方法 - 大白鲨 - 博客园 asp.net操作Excel拒绝访问的解决 利用javascript判断浏览器是否已经安装ActiveX控件和是否禁止运行ActiveX控件 IIS错误Server Application Error(http 500 错误)解决办法 SQL Server的SQL技巧 ASP.NET 2.0 实现多文件上传 网络MSDTC配置方法 visual studio 2005包加载失败的解决办法 Office Excel 2003找不到安装文件sku011.cab的解决办法 delphi连接DCOM的安全配置 Atlas中对DataTable操作的脚本 通过Web Services上传和下载图片文件 IIS 5.0错误解决集锦 访问IIS时返回的状态代码解释参考 使用UDPClient 编写聊天程序 Windows安全配置技术 为IIS配置安全的发布方法 SQL Server中各个系统表的作用
去掉asp.net2.0的树控件刷新功能
大白鲨 · 2006-09-06 · via 博客园 - 大白鲨

在选中树节点时,页面老是刷新。新的树控件中没有可以将刷新功能去掉的属性。如果设置节点的selectAction为None时由无法选中节点。现加入以下脚本去掉刷新功能,并保证能够选中节点时节点变颜色。
脚本文件为:

// JScript 文件
var selectnd=null;
function iniTree(TreeViewName)
{
   
var tre=document.getElementById(TreeViewName);
   
for(var i=0;i<tre.children.length;i++)
   
{
      iniChildnode(tre.children[i]);
   }

}


function iniChildnode(cnd)
{
   
if((cnd.tagName=="A")&&(cnd.className!=""))
   
{
      cnd.onclick
=clk;
      cnd.href
="#";
   }

   
else
   
{
      
for(var n=0;n<cnd.children.length;n++)
      
{
         iniChildnode(cnd.children[n]);
      }

   }

}


function clk()
{
   
if(selectnd!=null)
     selectnd.style.backgroundColor
="";
   
var nd=event.srcElement;
   nd.style.backgroundColor
="#C0FFFF";
   selectnd
=nd;
}

aspx文件为

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mstree.aspx.cs" Inherits="mstree" %>

<!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>
    
<script src ="JScript.js" type="text/javascript"></script>
</head>
<body onload="iniTree('Tree');">
    
<form id="form1" runat="server">
    
<div>
        
<asp:TreeView ID="Tree" runat="server" PopulateNodesFromClient="False" ShowLines="True">
            
<Nodes>
                
<asp:TreeNode Text="a" Value="a">
                    
<asp:TreeNode Text="a1" Value="a1"></asp:TreeNode>
                
</asp:TreeNode>
                
<asp:TreeNode Text="b" Value="b">
                    
<asp:TreeNode Text="b1" Value="b1"></asp:TreeNode>
                
</asp:TreeNode>
            
</Nodes>
            
<SelectedNodeStyle BackColor="#C0FFFF" BorderColor="Black" />
        
</asp:TreeView>
    
    
</div>
    
    
</form>
</body>
</html>