Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rune Grønkjær 1372 posts 3103 karma points MVP
    Apr 20, 2011 @ 11:33
    Rune Grønkjær
    0

    Dynamic number of Tabs

    Hi,

    How do I create a dynamic number of Tabs and still get access to the controls in the tabs?

    I need to loop through the Umbraco languages and create a tab for each language with some settings in each tab.

    Any ideas will be appreciated.

    /Rune

  • Jeroen Breuer 4909 posts 12266 karma points MVP 6x admin c-trib
    Apr 20, 2011 @ 11:43
    Jeroen Breuer
    0

    Do you want to create dynamic tabs on documenttype or a custom page for a custom section?

    Jeroen

  • Rune Grønkjær 1372 posts 3103 karma points MVP
    Apr 20, 2011 @ 11:45
    Rune Grønkjær
    0

    The latter, a custom page for a custom section!

  • Jeroen Breuer 4909 posts 12266 karma points MVP 6x admin c-trib
    Apr 20, 2011 @ 12:18
    Jeroen Breuer
    0

    Here is a sample of how I add multiple tabs to a page for a custom section:

    Frontend:

    <%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Title="Category details" AutoEventWireup="true" CodeBehind="CategoryDetails.aspx.cs" Inherits="UnidekCorporate.WebApplication.Sections.Products.Category.CategoryDetails" ValidateRequest="false" %>
    <%@ Register TagPrefix="UmbracoControls" Namespace="umbraco.uicontrols" Assembly="controls" %>
    <%@ Register TagPrefix="UmbracoControls" Namespace="umbraco.controls" Assembly="umbraco" %>

    <asp:Content ID="ContentPage" ContentPlaceHolderID="body" runat="server">
    <style type="text/css">
    .validationSummaryTop
    {
    margin-top: 10px;
    margin-bottom: 10px;
    }
    </style>

    <UmbracoControls:TabView ID="TabViewCategory" runat="server" Width="552px" Height="692px"/>

    <%--Details tab Webcontrols--%>
    <asp:Panel ID="PanelDetails" runat="server">

    <%--ValidationSummary--%>
    <asp:ValidationSummary runat="server" DisplayMode="BulletList" ID="ValidationSummaryDetails" CssClass="error validationSummaryTop" HeaderText="<h3>The data has not been saved because there are some errors you need to fix first:</h3>"></asp:ValidationSummary>

    <%--Backend Name--%>
    <UmbracoControls:Pane ID="PaneName" runat="server">
    <UmbracoControls:PropertyPanel ID="PropName" runat="server" Text="Name">
    <asp:TextBox ID="TxtName" runat="server" CssClass="umbEditorTextField"></asp:TextBox>
    </UmbracoControls:PropertyPanel>
    </UmbracoControls:Pane>
    </asp:Panel>

    <%--NL tab Webcontrols--%>
    <asp:Panel ID="PanelNL" runat="server">

    <%--ValidationSummary--%>
    <asp:ValidationSummary runat="server" DisplayMode="BulletList" ID="ValidationSummaryNL" CssClass="error validationSummaryTop" HeaderText="<h3>The data has not been saved because there are some errors you need to fix first:</h3>"></asp:ValidationSummary>

    <%--NL Name--%>
    <UmbracoControls:Pane ID="NLName" runat="server">
    <UmbracoControls:PropertyPanel ID="NLName" runat="server" Text="NL Name">
    <asp:TextBox ID="TxtNLName" runat="server" CssClass="umbEditorTextField"></asp:TextBox>
    </UmbracoControls:PropertyPanel>
    </UmbracoControls:Pane>

    </asp:Panel>

    </asp:Content>

    Codebehind:

    public partial class CategoryDetails : umbraco.BasePages.BasePage
    {
    public TabPage dataTab;

    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);

    #region Details Tab

    dataTab = TabViewCategory.NewTabPage("Details");
    dataTab.Controls.Add(PanelDetails);

    //Create a save button for the details tab.
    SetSaveButtonProperties("ImgBtnSaveDetails");

    #endregion

    #region NL Tab

    dataTab = TabViewCategory.NewTabPage("NL");
    dataTab.Controls.Add(PanelNL);

    //Create a save button for the details tab.
    SetSaveButtonProperties("ImgBtnSaveNL");

    #endregion
    }

    /// <summary>
    /// Set the properites of the savebutton for a tab.
    /// </summary>
    /// <param name="saveButton"></param>
    /// <param name="id"></param>
    private void SetSaveButtonProperties(string id)
    {
    //Create a save button from the current datatab.
    saveButtonData = dataTab.Menu.NewImageButton();
    saveButtonData.ID = id;
    saveButtonData.Click += new ImageClickEventHandler(SaveButton_Click);
    saveButtonData.AlternateText = "Save";
    saveButtonData.ImageUrl = GlobalSettings.Path + "/images/editor/save.gif";
    }
    }

    In this sample I add a details and NL tab. It's not in a loop, but you should be able get started with this :). For another example have a look at this wiki page: http://our.umbraco.org/wiki/reference/umbraco-best-practices/standard-ui-umbracouicontrols/umbracouicontrols-page-samples

    Jeroen

  • Rune Grønkjær 1372 posts 3103 karma points MVP
    Apr 20, 2011 @ 15:20
    Rune Grønkjær
    0

    Thanks Jeroen,

    I allready did that and then tried to loop it. Only problem is that I get a nasty error when I try to do it. Umbraco moves the panels I'm adding as Tabs. It cannot do that because they all have the same ID's in the ListView, where they where created.

    I have then tried to rename the panels - and all of their controls - BEFORE adding them to umbracos tabs with the AddTab() method. That works some of the way BUT when I click save, no Controls are there. The viewstate remembers nothing and I cannot access my data.

    /Rune

  • Jeroen Breuer 4909 posts 12266 karma points MVP 6x admin c-trib
    Apr 20, 2011 @ 15:41
    Jeroen Breuer
    0

    Hmm not sure what might cause this problem. I guess the best thing you can do is look into the Umbraco source code. All tabs you create on a documenttype are added dynamically if you open a node and the same goes for tabs on a mediatype. You should probably have a look at the editContent.aspx and editMedia.aspx pages in the source code.

    Jeroen

  • Rune Grønkjær 1372 posts 3103 karma points MVP
    Apr 20, 2011 @ 16:05
    Rune Grønkjær
    0

    really hoped I did'nt have to do that :)

    But I'm looking into it now. Will post back if I find a solution. Not before easter tough.

  • Rune Grønkjær 1372 posts 3103 karma points MVP
    Apr 27, 2011 @ 11:44
    Rune Grønkjær
    0

    Just so you know, I have submitted an Umbraco support ticket on this. Have been unable to figure it out from the Umbraco source.

    /Rune

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies