asp.net|treeview| Solution
Recently in doing permission module, very headache things. Does not include the permission part of the business, but also includes the permission part of the interface implementation. Because of the use of Microsoft's TreeView control to assign permissions, so the hot online discussion about the TreeView operation Refresh problem, with the help of the ancestors and colleagues, finally make the problem of the TreeView has been better resolved.
1, the front control expands, the contraction, the Check/uncheck, the backstage control selectedindexchanged.
Workaround:
Set AutoPostBack to false;
Add <body > in body
and wrote in Pageload:
String strtreename = "TreeView1";
String strref = Page.GetPostBackEventReference (TreeView1);
String strscript = "<script language=\" javascript\ "> \ n" + "<!--\ n" + "function Inittree ( {\ n "+" "+ Strtreename +". onSelectedIndexChange = function () {\ n ' + ' if (even T.oldtreenodeindex!=
Event.newtreenodeindex) \ n "+" this.queueevent (' onSelectedIndexChange ', Event.oldtreenodeindex + ', ' + event.newTr Eenodeindex); \ n "+" Window.settimeout (' "+ Strref.replace (" "," \ \ ") +" ', 0, ' JavaScript '); \ n "+"} \ n "+"} \ n "+"//--> \ n "+ </script>";
Page.registerclientscriptblock ("Inittree", strscript);
2, in the case of a checkbox. After selecting the checkbox in the foreground, the checkbox's state becomes confusing and some of the selected cases are lost. The problem is a bug in Microsoft's TREEVIEW.HTC, and the problem has not been found on the Internet for good solutions. Yesterday, I found a bull brother who solved the problem. He perfected the HTC file and added the effect of parent-child linkage in the case of a checkbox in HTC, which is a boon to those who need to implement this function and not familiar with JS, because it means you can implement this function without writing any code I'm really grateful. I'll give you the HTTP for this beef article: http://blog.csdn.net/cuike519/archive/2005/02/02/278271.aspx
3, for the SelectedIndexChanged, you can do further customization. If the fruit tree has three layers, you can make the click of the first layer, the second layer does not carry on the postback, only when the third layer is selected to postback.
This is actually in the 1th on the amendment, for the onselectedindexchange of the conditions to expand. The code above simply determines that if the new node is not the same node as the old one, it triggers the Selectedindexchange, executes the _dopostback, and you can do the control you want by changing the condition to the limit you want. But note that if the following statement ah, if not followed by the {number, if you want to add conditions, it means that there should be conditional execution of the following two sentences.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.