Пример #1
0
        /// <summary>
        /// High level routine that renders the actual control
        /// </summary>
        private void RenderControl()
        {
            // Generate the HTML for the tabs and script blocks
            RenderTabs();

            // Generate the HTML for the base page and embed
            // the script etc into the page
            Output = string.Format(TabControl.MasterTemplate,
                                   TabOutput, Script, SelectedTabCssClass,
                                   TabstripSeparatorHeight.ToString());
        }
Пример #2
0
        /// <summary>
        /// Creates various string properties that are merged into the output template.
        /// Creates the tabs and the associated script code.
        /// </summary>
        private void RenderTabs()
        {
            if (_Tabs != null)
            {
                // ActivateTab script code
                StringBuilder Script = new StringBuilder();

                // ShowTabPage script code
                StringBuilder Script2 = new StringBuilder();

                // HtmlTextWriter to handle output generation for the HTML
                StringBuilder  sb        = new StringBuilder();
                StringWriter   sw        = new StringWriter(sb);
                HtmlTextWriter tabWriter = new HtmlTextWriter(sw);

                tabWriter.WriteLine("<table border='0' cellspacing='0'><tr>");



                int count = -1;
                foreach (TabPage tab in _Tabs)
                {
                    bool isPageSelected = false;
                    isPageSelected = _Tabs.Count % 1 == 0;

                    if (!string.IsNullOrEmpty(tab.TabPageClientId) &&
                        tab.TabPageClientId == _SelectedTab)
                    {
                        isPageSelected = true;
                    }

                    count++;
                    string id = ClientID + "_" + count.ToString();

                    tabWriter.WriteBeginTag("td");

                    if (!string.IsNullOrEmpty(tab.Style) && !tab.Style.EndsWith(";"))
                    {
                        StringUtils.TerminateString(tab.Style, ";");
                    }

                    if (!TabHeight.IsEmpty)
                    {
                        tab.Style += "height:" + TabHeight.ToString() + ";";
                    }
                    if (!TabWidth.IsEmpty)
                    {
                        tab.Style += "width:" + TabWidth.ToString() + ";";
                    }

                    tabWriter.WriteAttribute("id", id);

                    string ActionLink = FixupActionLink(tab);

                    if (ActionLink != "" && tab.Enabled)
                    {
                        tabWriter.WriteAttribute("onclick", ActionLink);
                    }

                    if (_Tabs == null)
                    {
                        return;
                    }

                    if (tab.TabPageClientId != "" && tab.TabPageClientId == _SelectedTab)
                    {
                        tabWriter.WriteAttribute("class", SelectedTabCssClass);
                    }
                    else
                    {
                        tabWriter.WriteAttribute("class", TabCssClass);
                    }

                    if (tab.Style != "")
                    {
                        tabWriter.WriteAttribute("style", tab.Style);
                    }

                    tabWriter.Write(HtmlTextWriter.TagRightChar);

                    if (tab.TabImage != "")
                    {
                        tabWriter.Write("<img src='" + ResolveUrl(tab.TabImage) + "' style='margin: 0px 5px 0px 7px;' align='left' />\r\n");
                    }

                    tabWriter.Write(tab.Caption);

                    tabWriter.WriteEndTag("td");
                    tabWriter.Write("\r\n");
                }
                tabWriter.Write("</tr>");

                if (TabstripSeparatorHeight != Unit.Empty && TabstripSeparatorHeight.Value > 0.00)
                {
                    tabWriter.Write(
                        @"<tr>
    <td class='" + TabStripSeparatorCssClass + @"' colspan='" + TabPages.Count.ToString() + "' style='padding: 0px;height: " + TabstripSeparatorHeight.ToString() + @";'></td>
</tr>");
                }


                tabWriter.Write("</table>\r\n");



                TabOutput = sb.ToString();
                tabWriter.Close();
            }
        }