问题描述
<%@PageLanguage="C#"%><html><head><style><!--.skin1{cursor:default;font:menutext;position:absolute;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:10pt;width:120px;background-color:menu;border:1solidbuttonface;visibility:hidden;border:2outsetbuttonhighlight;}.menuitems{padding-left:15px;padding-right:10px;}--></style><scripttype="text/javascript"><!--Beginvarmenuskin="skin1";vardisplay_url=1;//ShowURLsinstatusbar?functionshowmenuie5(){if(event.srcElement.type!=undefined){vars=event.srcElement.id;varind=s.replace("TreeView1t","");s=s.replace("TreeView1t","TreeView1n");document.getElementById('one').url=event.srcElement.href;document.getElementById('one').innerText="Select";varch=document.getElementById(s);if(ch!=null){document.getElementById('two').url="javascript:TreeView_ToggleNode(TreeView1_Data,"+ind+","+s+",'',"+s+"Nodes)";document.getElementById('two').innerText="Expand\Collapse";}elsedocument.getElementById('two').outerHTML="<divid=twoclass=menuitemsurl=''></div>"varrightedge=document.body.clientWidth-event.clientX;varbottomedge=document.body.clientHeight-event.clientY;if(rightedge<ie5menu.offsetWidth)ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth;elseie5menu.style.left=document.body.scrollLeft+event.clientX;if(bottomedge<ie5menu.offsetHeight)ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight;elseie5menu.style.top=document.body.scrollTop+event.clientY;ie5menu.style.visibility="visible";}else{ie5menu.style.visibility="hidden";}returnfalse;}functionhidemenuie5(){ie5menu.style.visibility="hidden";}functionhighlightie5(){if(event.srcElement.className=="menuitems"){event.srcElement.style.backgroundColor="highlight";event.srcElement.style.color="white";if(display_url)window.status=event.srcElement.url;}}functionlowlightie5(){if(event.srcElement.className=="menuitems"){event.srcElement.style.backgroundColor="";event.srcElement.style.color="black";window.status="";}}functionjumptoie5(){if(event.srcElement.className=="menuitems"){if(event.srcElement.getAttribute("target")!=null)window.open(event.srcElement.url,event.srcElement.getAttribute("target"));elsewindow.location=event.srcElement.url;}}//End--></script></head><body><formid="form1"runat="server"><divid="ie5menu"class="skin0"onmouseover="highlightie5()"onmouseout="lowlightie5()"onclick="jumptoie5();"><divid="one"class="menuitems"url=""></div><divid="two"class="menuitems"url=""></div></div><asp:TreeViewID="TreeView1"runat="server"><Nodes><asp:TreeNodeText="a"Value="a"><asp:TreeNodeText="b"Value="b"><asp:TreeNodeText="c"Value="c"></asp:TreeNode></asp:TreeNode></asp:TreeNode><asp:TreeNodeText="cc"Value="cc"><asp:TreeNodeText="ccc"Value="ccc"><asp:TreeNodeText="cccc"Value="cccc"></asp:TreeNode></asp:TreeNode></asp:TreeNode></Nodes><SelectedNodeStyleBackColor="#C00000"/></asp:TreeView></form><scripttype="text/javascript">if(document.all){ie5menu.className=menuskin;document.getElementById('TreeView1').oncontextmenu=showmenuie5;document.body.onclick=hidemenuie5;}</script></body></html>这个用的是以前版本的treeview控件,想改成2.0的treeview控件,怎么改啊,功能不要变
解决方案
解决方案二:
不是上面的是下面这段代码TreeView.aspx<%@RegisterTagPrefix="iewc"Namespace="Microsoft.Web.UI.WebControls"Assembly="Microsoft.Web.UI.WebControls,Version=1.0.2.226,Culture=neutral,PublicKeyToken=31bf3856ad364e35"%><HTML><HEAD><title>TreeView控件右键菜单</title><style><!--.skin{cursor:default;font:menutext;position:absolute;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:10pt;width:120px;background-color:menu;border:1solidbuttonface;visibility:hidden;border:2outsetbuttonhighlight;}.menuitems{padding-left:15px;padding-right:10px;}--></style></HEAD><bodyonclick="hideMenu()"><formid="TreeView"method="post"runat="server"><iewc:TreeViewid="TreeView1"runat="server"ExpandLevel="3"HoverStyle="color:blue;background:#ffff00;"><iewc:TreeNodeText="Node0"Expanded="True"><iewc:TreeNodeText="Node3"><iewc:TreeNodeText="Node5"></iewc:TreeNode><iewc:TreeNodeText="Node6"></iewc:TreeNode></iewc:TreeNode><iewc:TreeNodeText="Node4"></iewc:TreeNode></iewc:TreeNode><iewc:TreeNodeText="Node1"Expanded="True"><iewc:TreeNodeText="Node7"><iewc:TreeNodeText="Node8"></iewc:TreeNode></iewc:TreeNode></iewc:TreeNode><iewc:TreeNodeText="Node2"Expanded="True"><iewc:TreeNodeText="Node9"></iewc:TreeNode><iewc:TreeNodeText="Node10"><iewc:TreeNodeText="Node11"></iewc:TreeNode><iewc:TreeNodeText="Node12"></iewc:TreeNode></iewc:TreeNode></iewc:TreeNode></iewc:TreeView><divid="popupMenu"class="skin"onMouseover="highlighItem()"onMouseout="lowlightItem()"onClick="clickItem()"><divclass="menuitems"func="add">添加</div><hr><divclass="menuitems"func="delete">删除</div><divclass="menuitems"func="modify">修改</div></div></form><scriptlanguage="javascript">varmenuskin="skin";varnode=null;functionhideMenu(){popupMenu.style.visibility="hidden";}functionhighlighItem(){if(event.srcElement.className=="menuitems"){event.srcElement.style.backgroundColor="highlight";event.srcElement.style.color="white";}}functionlowlightItem(){if(event.srcElement.className=="menuitems"){event.srcElement.style.backgroundColor="";event.srcElement.style.color="black";window.status="";}}functionclickItem(){if(event.srcElement.className=="menuitems"){if(event.srcElement.getAttribute("func")=="add"&&node!=null){varnewNode=TreeView1.createTreeNode();newNode.setAttribute("Text","newNode");node.add(newNode);}elseif(event.srcElement.getAttribute("func")=="delete"&&node!=null){node.remove();}elseif(event.srcElement.getAttribute("func")=="modify"&&node!=null){node.setAttribute("Text","hgknight");}}}functionTreeView1.oncontextmenu(){varnodeIndex=event.treeNodeIndex;if(typeof(nodeIndex)=="undefined"){node=null;returnfalse;}node=TreeView1.getTreeNode(nodeIndex);varrightedge=document.body.clientWidth-event.clientX;varbottomedge=document.body.clientHeight-event.clientY;if(rightedge<popupMenu.offsetWidth){popupMenu.style.left=document.body.scrollLeft+event.clientX-popupMenu.offsetWidth;}else{popupMenu.style.left=document.body.scrollLeft+event.clientX;}if(bottomedge<popupMenu.offsetHeight){popupMenu.style.top=document.body.scrollTop+event.clientY-popupMenu.offsetHeight;}else{popupMenu.style.top=document.body.scrollTop+event.clientY;}popupMenu.style.visibility="visible";returnfalse;}</script></body></HTML>
解决方案三:
右键点击treenode有add、delete、modify功能
解决方案四:
好多呀。这就研究了这些。
解决方案五:
你先写好右键菜单,菜单里有add,delete,modify,然后逐一写事件就可以了http://www.cnblogs.com/zhangpengshou/archive/2008/11/16/1334377.htmlhttp://dev.csdn.net/article/26/26468.shtm
解决方案六:
汗...up。
解决方案七:
csdn