本篇文章給大家分享的是有關ASP.NET中TreeView的作用是什么,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

專注于為中小企業(yè)提供成都網(wǎng)站設計、成都網(wǎng)站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)弋陽免費做網(wǎng)站提供優(yōu)質的服務。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上1000家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設實現(xiàn)規(guī)模擴充和轉變。
ASP.NET 2.0 的 TreeView 控件功能雖說強大,但其客戶端控制很遜色,本文將講解 TreeView 的客戶端實現(xiàn)原理,并實現(xiàn)兩個個性化操作:
(1) 節(jié)點的全部打開和關閉;
Client Side Expand/Collapse All Nodes For ASP.NET 2.0 TreeView.
(2) 只打開一個節(jié)點(關閉其他兄弟節(jié)點)。
Just one expanded node in ASP.NET 2.0 TreeView (When a client expand one node all other will collaps)
用記事本打開頁面源代碼,可以找到一下兩個腳本引用:
<script src="/WebUI/WebResource.axd?d=RAQeBcDUNuP9iuS8q3tNEw2&
t=633300220640000000" type="text/javascript"></script><script src="/WebUI/WebResource.axd?d=JuTdJhq3NM8Jq_RhssAkEg2&
t=633300220640000000" type="text/javascript"></script>
將"/WebUI/WebResource.axd?d=RAQeBcDUNuP9iuS8q3tNEw2& amp;t=633300220640000000"拷到地址欄尾,下載腳本,并以 .js 命名,另一個同樣操作。分析第二個腳本文件,可以看到TreeView的很多客戶端函數(shù),其中關鍵的一個 TreeView_ToggleNode 就是客戶端點擊時觸發(fā)的事件。
要想做個性化的操作,就得從 TreeView_ToggleNode 事件下手。我們無法更改.net封裝好的腳本,只有“重寫”。所謂的重寫就是在原來的函數(shù)之后添加一個同名函數(shù)(因為js對于同名函數(shù)只調(diào)用***一個)。
TreeView_ToggleNode 的原函數(shù):
function TreeView_ToggleNode(data, index, node, lineType, children) {
var img = node.childNodes[0];
var newExpandState;
try {
if (children.style.display == "none") {
children.style.display = "block";
newExpandState = "e";
if ((typeof(img) != "undefined") && (img != null)) {
if (lineType == "l") {
img.src = data.images[15];
}
else if (lineType == "t") {
img.src = data.images[12];
}
else if (lineType == "-") {
img.src = data.images[18];
}
else {
img.src = data.images[5];
}
img.alt = data.collapseToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));
}
}
else {
children.style.display = "none";
newExpandState = "c";
if ((typeof(img) != "undefined") && (img != null)) {
if (lineType == "l") {
img.src = data.images[14];
}
else if (lineType == "t") {
img.src = data.images[11];
}
else if (lineType == "-") {
img.src = data.images[17];
}
else {
img.src = data.images[4];
}
img.alt = data.expandToolTip.replace(/\{0\}/, TreeView_GetNodeText(node));
}
}
}
catch(e) {}
datadata.expandState.value = data.expandState.value.substring(0, index) +
newExpandState + data.expandState.value.slice(index + 1);}
以上就是ASP.NET中TreeView的作用是什么,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學到更多知識。更多詳情敬請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
                新聞名稱:ASP.NET中TreeView的作用是什么
                
                標題路徑:http://www.chinadenli.net/article30/piiiso.html
            
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、營銷型網(wǎng)站建設、域名注冊、網(wǎng)站營銷、建站公司、標簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)