예제 #1
0
        /// <summary>
        /// Creates a NavigationTrailtab for each item in a dataview
        /// </summary>
        /// <param name="useViewState"></param>
        /// <remarks>
        /// Please note that there must at least 4 data items and
        /// data item 1 and 3 are used for text and URL respectively
        /// </remarks>
        protected virtual void CreateMyControlHierarchy(bool useViewState)
        {
            IEnumerable resolvedDataSource = null;

            if (useViewState)
            {
                if ((this.ViewState["RowCount"] != null))
                {
                    resolvedDataSource = new object[int.Parse(this.ViewState["RowCount"].ToString(), CultureInfo.InvariantCulture) + 1];
                }
                else
                {
                    throw new CustomWebControlException("Unable to retrieve expected data from View State");
                }
            }
            else
            {
                resolvedDataSource = DataSource;
            }

            if ((resolvedDataSource != null))
            {
                foreach (DataRowView dataItem in resolvedDataSource)
                {
                    using (NavigationTrailTab myNavigationTrailTab = new NavigationTrailTab())
                    {
                        myNavigationTrailTab.Text   = dataItem[1].ToString();
                        myNavigationTrailTab.Action = dataItem[3].ToString();
                        mNavigationTrailTab.Add(myNavigationTrailTab);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Display Navigation Trail.
        /// </summary>
        /// <param name="writer"></param>
        /// <remarks></remarks>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer", "writer cannot be a null reference (Nothing in Visual Basic)!");
            }
            // Display the tabs
            int i = 0;

            for (i = 0; i <= mNavigationTrailTab.Count - 1; i++)
            {
                NavigationTrailTab objTab = (NavigationTrailTab)mNavigationTrailTab[i];
                using (HyperLink hyperLink = new HyperLink())
                {
                    hyperLink.RenderBeginTag(writer);
                    //hyperLink.CssClass = "NavigationTrail";
                    hyperLink.Text        = objTab.Text;
                    hyperLink.NavigateUrl = objTab.Action;
                    hyperLink.ToolTip     = objTab.ToolTip;
                    hyperLink.RenderEndTag(writer);
                    hyperLink.RenderControl(writer);
                }

                if (m_Orentation == Orientation.Horizontal)
                {
                    if (i < mNavigationTrailTab.Count - 1)
                    {
                        writer.Write("&nbsp;|&nbsp;");
                    }
                }
                else
                {
                    if (i < mNavigationTrailTab.Count - 1)
                    {
                        writer.Write("<br/>");
                    }
                }
            }
        }