日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
淺談ASP.NET中的TreeView

ASP.NET 2.0 的 TreeView 控件功能雖說(shuō)強(qiáng)大,但其客戶端控制很遜色,本文將講解 TreeView 的客戶端實(shí)現(xiàn)原理,并實(shí)現(xiàn)兩個(gè)個(gè)性化操作:

(1) 節(jié)點(diǎn)的全部打開(kāi)和關(guān)閉;
Client Side Expand/Collapse All Nodes For ASP.NET 2.0 TreeView.

(2) 只打開(kāi)一個(gè)節(jié)點(diǎn)(關(guān)閉其他兄弟節(jié)點(diǎn))。
Just one expanded node in ASP.NET 2.0 TreeView (When a client expand one node all other will collaps)
用記事本打開(kāi)頁(yè)面源代碼,可以找到一下兩個(gè)腳本引用:

 
 
 
  1.  
  2.  

將"/WebUI/WebResource.axd?d=RAQeBcDUNuP9iuS8q3tNEw2& amp;t=633300220640000000"拷到地址欄尾,下載腳本,并以 .js 命名,另一個(gè)同樣操作。分析第二個(gè)腳本文件,可以看到TreeView的很多客戶端函數(shù),其中關(guān)鍵的一個(gè) TreeView_ToggleNode 就是客戶端點(diǎn)擊時(shí)觸發(fā)的事件。

要想做個(gè)性化的操作,就得從 TreeView_ToggleNode 事件下手。我們無(wú)法更改.net封裝好的腳本,只有“重寫(xiě)”。所謂的重寫(xiě)就是在原來(lái)的函數(shù)之后添加一個(gè)同名函數(shù)(因?yàn)閖s對(duì)于同名函數(shù)只調(diào)用***一個(gè))。

TreeView_ToggleNode 的原函數(shù):

 
 
 
  1. function TreeView_ToggleNode(data, index, node, lineType, children) {  
  2. var img = node.childNodes[0];  
  3. var newExpandState;  
  4. try {  
  5. if (children.style.display == "none") {  
  6. children.style.display = "block";  
  7. newExpandState = "e";  
  8. if ((typeof(img) != "undefined") && (img != null)) {  
  9. if (lineType == "l") {  
  10. img.src = data.images[15];  
  11. }  
  12. else if (lineType == "t") {  
  13. img.src = data.images[12];  
  14. }  
  15. else if (lineType == "-") {  
  16. img.src = data.images[18];  
  17. }  
  18. else {  
  19. img.src = data.images[5];  
  20. }  
  21. img.alt = data.collapseToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));  
  22. }  
  23. }  
  24. else {  
  25. children.style.display = "none";  
  26. newExpandState = "c";  
  27. if ((typeof(img) != "undefined") && (img != null)) {  
  28. if (lineType == "l") {  
  29. img.src = data.images[14];  
  30. }  
  31. else if (lineType == "t") {  
  32. img.src = data.images[11];  
  33. }  
  34. else if (lineType == "-") {  
  35. img.src = data.images[17];  
  36. }  
  37. else {  
  38. img.src = data.images[4];  
  39. }  
  40. img.alt = data.expandToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));  
  41. }  
  42. }  
  43. }  
  44. catch(e) {}  
  45. datadata.expandState.value =  data.expandState.value.substring(0, index) + 
    newExpandState + data.expandState.value.slice(index + 1);  

【編輯推薦】

  1. ASP.NET的TypeConverter
  2. 淺析ASP.NET的TypeResolver
  3. ASP.NET中定義JavaScriptConverter
  4. 在ASP.NET中替換Sys.Services的方法
  5. 使用ASP.NET AJAX的Profile Service

分享名稱:淺談ASP.NET中的TreeView
分享地址:http://www.5511xx.com/article/ccsoghp.html