`

继承TreeNode,使其在客户端显示Value

    博客分类:
  • asp
asp 
阅读更多

asp.net  中的TreeView控件,如果把它TreeNode的SelectAction属性设置成TreeNodeSelectAction.None,也就是不进行回发,那么 dopostback也就在客户端不存在了,对应的Value也不会呈现在客户端,这对于想通过js在客户端编程造成了困难,解决的方法是,继承现有的TreeNode来解决这个问题

 

[csharp] view plaincopy
  1. public class ValueTreeNode : TreeNode  
  2.     {  
  3.         protected override void RenderPreText(HtmlTextWriter writer)  
  4.         {  
  5.             base.RenderPreText(writer);  
  6.             writer.AddAttribute("spanvalue",Value); //不能是value,否则在用jQuery时取不到值  
  7.         }  
  8.   
  9.         public ValueTreeNode(String text,String value) : base(text,value)  
  10.         {  
  11.   
  12.         }  
  13.   
  14.         public ValueTreeNode(TreeNode node)  
  15.             : base(node.Text,node.Value)  
  16.         {  
  17.   
  18.         }  
  19.     }  
3
9
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics