问题描述
在一个页面中有一个TreeView控件,当选中对应的节点时根据路径跳转到对应的页面,这样在跳转页面的同时TreeView控件也存在刷新的过程,请大家各位帮帮忙。
解决方案
解决方案二:
使用局部刷新,updatepannel,将TreeView控件放到里面
解决方案三:
一个变态的方法,慎用!包含Treeview控件的部分用一个iframe替换,同时此iframesrc="ChannelTree.aspx"<iframeid="TreeView"frameborder="0"src="ChannelTree.aspx"width="0"height="0"></iframe>此ChannelTree.aspx只负责展现,没有服务器端事件ChannelTree.aspx前台:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="ChannelTree.aspx.cs"Inherits="ChannelTree"%><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><asp:TreeViewID="TreeView1"runat="server"ShowLines="True"><SelectedNodeStyleBackColor="Gainsboro"BorderColor="White"/></asp:TreeView></form></body></html>
ChannelTree.aspx后台protectedvoidPage_Load(objectsender,EventArgse){TreeNodetreeNodeRoot=newTreeNode("导航","-1");treeNodeRoot.NavigateUrl=string.Format("javascript:void(Navigator('{0}'))","-1");TreeNodetreeNode;NavigatorHelpernvh=newNavigatorHelper();foreach(KeyValuePair<string,string>deinnvh.GetNavigator()){treeNode=newTreeNode();treeNode.Text=de.Value;treeNode.Value=de.Key;treeNode.NavigateUrl=string.Format("javascript:void(Navigator('{0}'))",de.Key);treeNodeRoot.ChildNodes.Add(treeNode);}this.TreeView1.Nodes.Add(treeNodeRoot);this.TreeView1.ExpandAll();}publicoverridevoidVerifyRenderingInServerForm(Controlcontrol){}protectedoverridevoidRender(HtmlTextWriterwriter){StringBuildersb=newStringBuilder();sb.Append("<tableborder="0"cellpadding="0"cellspacing="0"width="100%">");sb.AppendLine("<tr>");sb.AppendLine("<tdalign="left"valign="top">");sb.AppendLine("<selectname="DropDownListNavigator"id="DropDownListNavigator">");sb.AppendLine("<optionselected="selected"value="ChannelName">按类型导航</option>");sb.AppendLine("</select>");sb.AppendLine("</td>");sb.AppendLine("</tr>");sb.Append("</table>");writer.Write(sb.ToString());this.TreeView1.RenderControl(writer);}
解决方案四:
不好意思,搞混了,用TreeView控件用一个Div替换,同时ajax的方式请求ChannelTree.aspx填充此Div在主页面上定义Navigator方法不用iframe!