1

Closed

Possible issue

description

Hi,   First, great job!   Now the problem. I'm creating tabs dinamically. While tabs creation is OK, tabs behavior seems erratic some times.   1. First click issue: After create tabs dinamically first click never triggers the event : this.TabStrip1.TabItemClicked += new SCS.Web.UI.WebControls.TabStrip.ItemClickedHandler(this.TabStrip1_TabItemClicked); Even if the event does not triggers, the tabs color changes (all tabs become grays...tabs' color set to default)   2. if there are many tabs created and screen space is not enough, tabstrip creates a second or thrid line, which is fine; However, when clicking in any tab, instead to keep tabs alignment, an empty space (clicked tab width) appears in the second line.   3. selected tab color does not change (code below): TabStrip1.TabSelectedTextStyle.BorderColor = System.Drawing.Color.Blue; TabStrip1.TabSelectedTextStyle.Font.Bold = true;   I'm attaching the complete code, and an image of control after first click, so you can analyse it and see if I'm doing something wrong.   <%@ Import namespace="DNNContentBuilder" %> <%@ Control Language="c#" AutoEventWireup="false" Inherits="DNNContentBuilder.UserControls.TemplateWorkbenchControl" %> <%@ Register Assembly="SCS.TabStrip" Namespace="SCS.Web.UI.WebControls" TagPrefix="SCS" %> <%@ Register TagPrefix="my" Namespace="FunkeLab" Assembly="MyTreeView" %>  
' colSpan=3 height=10>
<asp:imagebutton id="btRefresh" ImageUrl="~/DesktopModules/DNNContentBuilder/images/btRefresh.gif" ImageAlign=AbsMiddle runat="server" />    <asp:imagebutton id="btNewFolder" ImageUrl="~/DesktopModules/DNNContentBuilder/images/btNewFolder.gif" ImageAlign=AbsMiddle runat="server" />    <asp:imagebutton id="btDelFolder" ImageUrl="~/DesktopModules/DNNContentBuilder/images/btDelFolder.gif" ImageAlign=AbsMiddle runat="server" />    <asp:TextBox Runat="server" Text="" font-size="XX-Small" maxlength="128" width="100" ID="txtTemplateName" />   <asp:imagebutton id="btCreateFolder" ImageUrl="~/DesktopModules/DNNContentBuilder/images/btCreateFolder.gif" runat=server />   <asp:imagebutton id="btCancelFolder" ImageUrl="~/DesktopModules/DNNContentBuilder/images/btCancelFolder.gif" runat=server />

<my:MyTreeView ID="TreeView" Runat="server" />
 
<asp:PlaceHolder ID="TabStripItems" runat="server" Visible="true"><SCS:TabStrip ID="TabStrip1" runat="server" BackColor="255, 255, 204"> <Items> <SCS:TabItem Tag="Untitled" Text="Untitled" Selected=True /> </Items> <TabTextHoverStyle Font-Underline="False" /> <TabTextStyle Font-Names="Verdana" Font-Size="XX-Small" /> </SCS:TabStrip> </asp:PlaceHolder>

<TEXTAREA id="txtScript" style="WIDTH: 100%; COLOR: blue; HEIGHT: 100%;" rows="21" wrap="hard" cols="80" runat="server" ></TEXTAREA> <INPUT type=hidden runat=server id="txtTab" />
<asp:linkbutton id="btUpdate" runat="server" CssClass="CommandButton"></asp:linkbutton>   <asp:linkbutton id="btDelete" Visible="false" runat="server" CssClass="CommandButton">    </asp:linkbutton> <asp:linkbutton id="btDetails" Visible="false" runat="server" CssClass="CommandButton">    </asp:linkbutton> <asp:linkbutton id="btCancel" runat="server" CssClass="CommandButton"></asp:linkbutton>

  CODE BEHIND   /* DNN Content Builder - www.redrails.net Copyright (c) 2004-2007 by Emerson Lopes (emersonlopes@gmail.com)   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */   namespace DNNContentBuilder.UserControls { using System; using System.Collections; using System.IO; using System.Text; using System.Web; using System.Web.UI; using SCS; using SCS.Web; using SCS.Web.UI.WebControls; /* using (FileStream fs = File.Open(System.Web.HttpContext.Current.Server.MapPath(@"DesktopModules\DNNContentBuilder\templates\" + this.ddFiles.SelectedValue),FileMode.Create, FileAccess.Write,FileShare.None)) { byte[] buffer = System.Text.Encoding.UTF8.GetBytes(System.Web.HttpUtility.HtmlDecode(txtScript.Value));   fs.Write(buffer,0,buffer.Length);   fs.Flush(); }   */ /// <summary> /// Summary description. /// </summary> public class TemplateWorkbenchControl : DotNetNuke.Entities.Modules.PortalModuleBase { public const string resource = "~/DesktopModules/DNNContentBuilder/App_LocalResources/TemplateWorkbenchControl"; protected string folderIcon = "folderIcon.gif"; protected string fileIcon = "fileIcon.gif"; private string selectedNode = "-1"; protected FunkeLab.MyTreeView TreeView;   protected System.Web.UI.WebControls.ImageButton btRefresh; protected System.Web.UI.WebControls.ImageButton btNewFolder; protected System.Web.UI.WebControls.ImageButton btDelFolder; protected System.Web.UI.WebControls.TextBox txtTemplateName; protected System.Web.UI.WebControls.ImageButton btCreateFolder; protected System.Web.UI.WebControls.ImageButton btCancelFolder; protected SCS.Web.UI.WebControls.TabStrip TabStrip1; protected System.Web.UI.WebControls.PlaceHolder TabStripItems;   protected System.Web.UI.WebControls.LinkButton btUpdate; protected System.Web.UI.WebControls.LinkButton btDelete; protected System.Web.UI.WebControls.LinkButton btCancel; protected System.Web.UI.WebControls.LinkButton btDetails; protected System.Web.UI.HtmlControls.HtmlTextArea txtScript; protected System.Web.UI.HtmlControls.HtmlInputHidden txtTab; private void Page_Load(object sender, System.EventArgs e) { //Coding can be a time consuming task... Session.Timeout += 10; // Put user code to initialize the page here if (!this.IsPostBack) { this.btCreateFolder.Visible = false; this.btCancelFolder.Visible = false; this.txtTemplateName.Visible = false; this.btDelete.Visible = false; this.btDetails.Visible = false; } else { this.btDelete.Attributes.Add("onClick", "javascript:return confirm('" + Commons.GetLocalizedString("label_ConfirmDelete", resource) + "')"); SetSelectedNode(); }   BuildTreeview();   this.btDetails.Text = Commons.GetLocalizedString("button_Details", resource); this.btCancel.Text = Commons.GetLocalizedString("button_Cancel", resource); this.btDelete.Text = Commons.GetLocalizedString("button_Delete", resource); this.btUpdate.Text = Commons.GetLocalizedString("button_Update", resource); } private void BuildTreeview() { TreeView.Items.Clear(); string path = (Page).ResolveUrl("~/DeskTopModules/DNNContentBuilder/images/");   TreeView.FontSize = 2;   FunkeLab.MyTreeView.ImagesFolder = path; FunkeLab.MyTreeViewItem item = new FunkeLab.MyTreeViewItem(); item.Text = "Templates"; item.Open = true; item.Image = (Page).ResolveUrl("~/DeskTopModules/DNNContentBuilder/images/") + folderIcon; item.Value = "-1"; if (selectedNode == "-1") { item.Selected = true; } else { item.Selected = false; } item.Selector = FunkeLab.MyTreeViewItem.SelectionMode.RadioButton; this.TreeView.Items.Add(item);   path = HttpContext.Current.Server.MapPath(@"~\DesktopModules\DNNContentBuilder\Templates");   CreateNode(item.Value, item, path);   TreeView.OpenAll(); } private FunkeLab.MyTreeViewItem CreateNode(string parent, FunkeLab.MyTreeViewItem localItem, string path) { string[] folders = Directory.GetDirectories(path); foreach (string folder in folders) { FunkeLab.MyTreeViewItem item = new FunkeLab.MyTreeViewItem();   item.Text = folder.Substring(folder.LastIndexOf("\\") + 1); item.Value = folder; if (item.Value == selectedNode) { item.Selected = true; } item.Selector = FunkeLab.MyTreeViewItem.SelectionMode.RadioButton; item.Image = (Page).ResolveUrl("~/DeskTopModules/DNNContentBuilder/images/") + folderIcon;   localItem.Items.Add(CreateNode(folder, item, folder)); } string[] files = Directory.GetFiles(path, "*.ascx"); System.Collections.SortedList sortedList = new SortedList();   foreach (string file in files) { sortedList.Add(file, file); } foreach (string file in sortedList.Keys) { FunkeLab.MyTreeViewItem myItem = new FunkeLab.MyTreeViewItem(); myItem.Text = file.Substring(file.LastIndexOf("\\") + 1); myItem.Value = file; myItem.Image = (Page).ResolveUrl("~/DeskTopModules/DNNContentBuilder/images/") + fileIcon;   localItem.Items.Add(myItem); } return localItem; }   #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.TabStrip1.TabItemClicked += new SCS.Web.UI.WebControls.TabStrip.ItemClickedHandler(this.TabStrip1_TabItemClicked); this.btRefresh.Click += new ImageClickEventHandler(btRefresh_Click); this.btNewFolder.Click += new ImageClickEventHandler(btNewFolder_Click); this.btCancelFolder.Click += new ImageClickEventHandler(btCancelFolder_Click); this.btUpdate.Click += new System.EventHandler(this.btUpdate_Click); this.btDelete.Click += new System.EventHandler(this.btDelete_Click); this.btCancel.Click += new System.EventHandler(this.btCancel_Click); this.TreeView.OnNodeClick += new FunkeLab.MyTreeView.OnNodeClickEventHandler(OnNodeClick); } #endregion   private void btUpdate_Click(object sender, System.EventArgs e) { } private void btCancel_Click(object sender, System.EventArgs e) { }   private void btDelete_Click(object sender, System.EventArgs e) { }   private void btDetails_Click(object sender, System.EventArgs e) { } private void btNewFolder_Click(object sender, System.EventArgs e) { this.btCreateFolder.Visible = true; this.btCancelFolder.Visible = true; this.txtTemplateName.Visible = true;   this.btRefresh.Visible = false; this.btNewFolder.Visible = false; this.btDelFolder.Visible = false; }   private void btCancelFolder_Click(object sender, System.EventArgs e) { this.btCreateFolder.Visible = false; this.btCancelFolder.Visible = false; this.txtTemplateName.Visible = false; this.btRefresh.Visible = true; this.btNewFolder.Visible = true; this.btDelFolder.Visible = true; }   private void SetSelectedNode() { string radio = TreeView.UniqueID.Replace("TreeView", "");   if (Page.Request.Form.Get(radio) != null) { selectedNode = Page.Request.Form.Get(radio); } selectedNode = selectedNode == "" ? "-1" : selectedNode; } private void btRefresh_Click(object sender, System.EventArgs e) { BuildTreeview(); }   protected void TabStrip1_TabItemClicked(object sender, SCS.Web.UI.WebControls.TabItemClickedEventArgs e) { string currentTab = Normalize(txtTab.Value); if (currentTab == "" || currentTab == null) { currentTab = txtTab.Value = e.SelectedTabItem.Tag; Session[Normalize(currentTab)] = txtScript.Value; }   Session[Normalize(currentTab)] = txtScript.Value; txtTab.Value = e.SelectedTabItem.Tag; txtScript.Value = (string)Session[e.SelectedTabItem.Tag]; } protected void OnNodeClick(ref FunkeLab.MyTreeViewItem item) { // Ignore click on folders if (item.Selector == FunkeLab.MyTreeViewItem.SelectionMode.RadioButton) { return; } string currentTab = Normalize(txtTab.Value); if (currentTab == "" || currentTab == null) { currentTab = txtTab.Value = Normalize(item.Value); }   // Save current script into corr hidden (recreating the hidden) string hid = (string)Session[Normalize(currentTab)]; if (hid != null) { Session[Normalize(currentTab)] = txtScript.Value; } //check if template is open already //open file, create tab, update script, show script bool isOpened = false;   string script = "File not found!"; foreach (SCS.Web.UI.WebControls.TabItem tabItem in TabStrip1.Items) { if (tabItem.Tag == Normalize(item.Value)) { isOpened = true; script = (string)Session[Normalize(item.Value)]; tabItem.Selected = true; break; } }   // Se não está aberto... if (!isOpened) { TemplateDefinitionController tdController = new TemplateDefinitionController(); TemplateDefinitionInfo tdInfo;   tdInfo = tdController.GetItemByName(item.Value); // se não existe no db, crie if (tdInfo == null) { tdInfo = new TemplateDefinitionInfo(); if (File.Exists(item.Value)) { using(StreamReader source = File.OpenText(item.Value)) { script = source.ReadToEnd(); } }   tdInfo.Body = script; tdInfo.TemplateName = item.Value; tdController.Add(tdInfo); } else { script = tdInfo.Body; } // crie e atribua o script ao hidden, tabstrip e ao editor SCS.Web.UI.WebControls.TabItem tabItem = new TabItem(); tabItem.Tag = Normalize(item.Value); tabItem.Text = item.Value.Substring(item.Value.LastIndexOf("\\") + 1); tabItem.Selected = true;   TabStrip1.Items.Add(tabItem);   Session[tabItem.Tag] = script; } TabStrip1.TabSelectedTextStyle.BorderColor = System.Drawing.Color.Blue; TabStrip1.TabSelectedTextStyle.Font.Bold = true;   txtTab.Value = Normalize(item.Value); txtScript.Value = script; } private string Normalize(string str) { string toReturn = str.Replace("\\","").Replace(":","").Replace(".",""); return toReturn; } } }

file attachments

Closed Nov 11, 2008 at 9:43 PM by wdavidsen

1 & 3 have been fixed. # 2 -- tabstrip does not currently support wrapping.


comments

wdavidsen wrote Jan 22, 2008 at 12:37 AM

Issue #1 has been fixed with the 1.2 release. I will look into issue #2 soon; although if you have that many tabs you may want to consider my MultiMenu control instead. Issue #3a: BorderColor is not supported by the control because the color of the tabs their borders are determinded by the image builder alone. A future release will have the BorderColor property hidden. Issue #3b has been fixed with release 1.2.

wrote Jan 22, 2008 at 12:37 AM

wrote Nov 11, 2008 at 9:43 PM

wrote Feb 13, 2013 at 10:13 PM

wrote May 16, 2013 at 2:02 AM