Hi,
I am using utrawebtab and ultrawebtree of version 8.2.The treeview is popuiated on page load and child nodes are populated on nodeexpanded event.on click on chid node the tab is created dynamically and added to ultrawebtab.I have set enableviewstate=true of ulrawebtab for maintaining state of tabs on postbacks.i am showing pdf,jpg,jpeg etc files in tabs.is it right way to maintan state of tabs on postback? when i change the of browser tab and do some other work and again come to my webpage i found that the tab is getting refreshed and pdf is scrolled to first page.which is best possible way which will avoid reloading of tabs on postback and maintain scroll position of pdf files in tab.
<div id="dvContent" class="x-panel-body" style="position: absolute; top: 55px; display: block; bottom: 0px; width: 100%; border-style: none;"> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline"> <ContentTemplate> <asp:Panel ID="pnl" runat="server"> <ignav:UltraWebTree ID="TreeView1" runat="server" EnableAppStyling="False" EnableViewState="true" CssClass="featureTree" Style="cursor: pointer; overflow: auto; overflow-x: hidden; display: block; position: absolute; height: 100%; top: 0px; width: 100%; bottom: 5px;" EnableTheming="false" Visible="true" AutoPostBack="false" ClientIDMode="Static" WebTreeTarget="ClassicTree" OnNodeClicked="TreeView1_NodeClicked" OnNodeExpanded="TreeView1_NodeExpanded"> </ignav:UltraWebTree> </asp:Panel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="TreeView1" EventName="NodeExpanded" /> <asp:AsyncPostBackTrigger ControlID="rpsearch" EventName="ItemCommand" /> </Triggers> </asp:UpdatePanel> </div>
<div class="ui-layout-center" style="height: 100%"> <div class="ui-layout-content" style="height: 100%"> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" RenderMode="Inline"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" Height="100%" Style="z-index: 0;"> <igtab:UltraWebTab ID="tabControl" BorderStyle="None" runat="server" Style="border-spacing: 0px;" AutoPostBack="false" ViewStateMode="Enabled" DisplayMode="Scrollable" LoadAllTargetUrls="false" EnableAppStyling="True" EnableTheming="true" Height="100%" EnableViewState="true" ThreeDEffect="false" Width="100%" SelectedTab="-1" Visible="false" ClientIDMode="Static" BrowserTarget="Auto"> <RoundedImage FillStyle="LeftMergedWithCenter" NormalImage="imageedit_2_2287647459.jpg" SelectedImage="imageedit_13_4149283003.jpg" HoverImage="imageedit_16_3964612111.jpg" /> <ScrollButtons LeftButton-Image="prev_up_new.gif" LeftButton-DisabledImage="prev_disabled_new.gif" LeftButton-HoverImage="prev_hover_new.gif" LeftButton-PressedImage="prev_down_new.gif"> </ScrollButtons> <ScrollButtons RightButton-Image="next_up_new.gif" ShowPartialTabs="true" AllowScrollToLastTab="true" UseBrowserDefaults="true" RightButton-DisabledImage="next_disabled_new.gif" RightButton-HoverImage="next_hover_new.gif" RightButton-PressedImage="next_down_new.gif"> </ScrollButtons> </igtab:UltraWebTab> </asp:Panel> </ContentTemplate> <%--<Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" /> <%--<asp:AsyncPostBackTrigger ControlID="tabControl" EventName="TabClick" /> </Triggers>--%> </asp:UpdatePanel> </div> </div>
protected void Page_Load(object sender, EventArgs e) { Session["LoginID"] = 1; if (Session["LoginID"] == null) { Response.Redirect("Login.aspx"); } Node tNode = null; if (!IsPostBack) { //Session["LoginID"]="1"; PopulateTree(tNode); this.Title = "Object Reader"; } }
public void PopulateTree(Node tNode) { DataTable dt = null; try { if (tNode != null) tNode.Nodes.Clear(); if (tNode == null) { TreeView1.Nodes.Clear(); using (ListenerDMethods dMethods = new ListenerDMethods()) { dt = dMethods.GetDataTable("[info].[UspObjectQueryMaster]", "@LoginID", Session["LoginID"].ToString(), //"@LoginID", "1", //"@LoginID", "1", "@QueryType", "ROOT_NODE" ); } if (dt != null || dt.Rows.Count > 0) { DataRow dRow = dt.Rows[0]; tNode = new Node(); tNode.Text = dRow["ObjectName"].ToString(); tNode.Tag = 0; SetImage(tNode, (ObjectType)(dRow["ObjectType"].ToInt32())); TreeView1.Nodes.Add(tNode); } } else { using (ListenerDMethods dMethods = new ListenerDMethods()) { dt = dMethods.GetDataTable("[info].[UspTree]", //"@LoginID", "1", "@LoginID", Session["LoginID"].ToString(), "@ObjectID", tNode.Tag.ToString(), "@ModuleType", "2".ToString() ); } DataView dv = new DataView(dt, "", UserOrderString, DataViewRowState.CurrentRows); dt = dv.ToTable(); } FillNode(dt, tNode); if (!tNode.Expanded) tNode.Expand(true); TreeView1.SelectedNode = tNode; //UpdatePanel1.Update(); } catch (Exception ex) { } finally { dt = null; } }
protected void TreeView1_NodeClicked(object sender, WebTreeNodeEventArgs e) { OpenSelectedFile(e.Node.Tag.ToString()); } protected void TreeView1_NodeExpanded(object sender, WebTreeNodeEventArgs e) { Node tNode = (e.Node as Node); if (tNode != null) PopulateTree(tNode); }
private void OpenSelectedFile(string ObjectID) { DataTable dt = null; DataTable dt1 = null; Tab tab = null; string URL = string.Empty; Node node = TreeView1.SelectedNode; try { using (ListenerDMethods dMethods = new ListenerDMethods()) { dt1 = dMethods.GetDataTable(Common.Entity.Usp.ObjectChecking, "@LoginID", Session["LoginID"].ToString(), //"@LoginID", "1", "@ObjectID", ObjectID.ToString() ); dt = dMethods.GetDataTable("[info].[UspObjectAddress]", //"@LoginID", "1", "@LoginID", Session["LoginID"].ToString(), "@ObjectID", ObjectID.ToString() ); if (dt != null && dt.Rows.Count > 0) { DataRow dRow = dt.Rows[0]; if (!dRow["HaveRights"].ToBoolean()) this.ClientScript.RegisterStartupScript(typeof(string), "alert", "<script type=\"text/javascript\"> jAlert('" + dRow["ErrorMessage"].NullToString() + "', 'Object reader','error');</script>", false); else { tab = tabControl.Tabs.FromKeyTab(dRow["ObjectName"].ToString()); if (tab != null) { tabControl.SelectedTab = tabControl.Tabs.GetTabIndex(tab); } else { tab = new Tab(); //tab.Text = dRow["ObjectName"].ToString(); tab.Text = string.Format("{0}{1}", string.Empty.PadRight(2), dRow["ObjectName"]) + "<img src='icons/close_button.gif' style='vertical-align:middle;padding-left:8px'onmouseover='mousein(event)' onmouseout=mouseout(event) onclick='closeTab("" + dRow["ObjectName"].ToString() + "")'>"; //tab.Text = dRow["ObjectName"].ToString(); tab.DefaultImage = node.ImageUrl; tab.ImageAlign = ImageAlign.AbsMiddle; //tab.DefaultImage.PadRight(100,'8'); tab.Key = dRow["ObjectName"].ToString(); tabControl.Tabs.Add(tab); } switch (dRow["ObjectType"].ToInt32()) { case 3: if (dRow["IIS"].ToBoolean()) { tab.ContentPane.TargetUrl = dRow["HTTPAddress"].MakeValid_WebAddress().ToString(); tab.Tag = URL; } else { string HDDAddress = string.Format(@"{0}{1}", "~/Uploads/", dRow["ObjectName"]); byte[] bytes = (byte[])dRow["ObjectContent"]; using (FileStream fs = new FileStream(Server.MapPath(HDDAddress), FileMode.OpenOrCreate, FileAccess.Write)) { fs.Write(bytes, 0, bytes.Length); fs.Dispose(); fs.Close(); } URL = Page.ResolveUrl(HDDAddress); tab.ContentPane.TargetUrl = URL; //tab.ContentPane.Controls.Add(new LiteralControl("<iframe src=\"" + URL + "\"; height = \"97%\"; width = \"99%\";z-index=\"-1\";></iframe>")); tab.Tag = URL; } break; case 6: tab.ContentPane.TargetUrl = dRow["ObjectLinkName"].MakeValid_WebAddress().ToString(); tab.Tag = URL; break; } tab.Visible = true; tab.Enabled = true; tabControl.SelectedTab = tabControl.Tabs.GetTabIndex(tab); tabControl.SelectedTabStyle.Font.Bold = true; tabControl.Visible = true; UpdatePanel2.Update(); } } } } catch (Exception ex) { throw ex; } finally { } }
Hello Prajakta,
Please note that version 8.2 of Net Advantage for ASP.NET is outdated and is no longer supported. In this scenario I would suggest considering updating to the AIKIDO WebTab control in order to be able to control the scroll position of individual tabs. WebTab's tab objects feature ScrollTop and ScrollBottom properties which allow setting the position of the tab scrollbar. Scrollbar position is also maintained by default in that component.
Online samples demonstrating the features of WebTab may be found at:
http://ko.infragistics.com/products/aspnet/sample/tab/add-edit-and-delete-tabs
In order to be able to investigate your particular scenario, a working sample with all data files would be greatly appreciated. Please do not hesitate to contact me with any updates or questions.
Please feel free to contact me if you have any questions regarding this matter.