示例#1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            EnsureChildControls();

            IEnumerable <IModelValidator> validators = GetErrors();

            foreach (IModelValidator validator in validators)
            {
                HtmlGenericControl errorListItem = new HtmlGenericControl("li")
                {
                    InnerText = validator.ErrorMessage
                };
                _errorList.Controls.Add(errorListItem);
            }

            _errorList.Visible = _errorList.HasControls();

            if (_errorList.Visible)
            {
                Style[HtmlTextWriterStyle.Display] = "inline-block";
            }
            else
            {
                Style[HtmlTextWriterStyle.Display] = "none";
            }
        }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //put the active id on current menu
        string page = Request.RawUrl.Substring(1).Replace(".aspx", string.Empty);

        page = page.Replace("OrchardRetreat/", string.Empty);
        page = page.Substring(0, 1).ToUpper() + page.Substring(1);


        HtmlGenericControl activeMenu = null;

        try
        {
            activeMenu = (HtmlGenericControl)FindControl("mnu_" + page);

            if (activeMenu.HasControls()) //remove anchor element
            {
                activeMenu.InnerHtml = @"<a id=""active"">" + page + "</a>";
            }
        }
        catch
        {
            //page does not have mnu_ control
        }
    }
示例#3
0
        private void CreateChildControlsStandard()
        {
            HtmlGenericControl container = null;
            Control            ctrl      = null;

            try
            {
                container = new HtmlGenericControl("div");

                ctrl = this.CreateLogo();
                if (ctrl != null)
                {
                    container.Controls.Add(ctrl);
                }

                ctrl = this.CreateHeaderLinks();
                if (ctrl != null)
                {
                    container.Controls.Add(ctrl);
                }

                if (container.HasControls())
                {
                    container.Attributes["class"] = "Mp_Hdr";

                    this.Controls.Add(container);
                }
            }
            finally
            {
                if (container != null)
                {
                    container.Dispose();
                }

                if (ctrl != null)
                {
                    ctrl.Dispose();
                }
            }
        }
示例#4
0
        private void CreateChildControlsModern()
        {
            HtmlGenericControl mainContainer = null;
            HtmlGenericControl container     = null;
            HtmlGenericControl leftContainer = null;
            Control            ctrl          = null;

            try
            {
                container     = new HtmlGenericControl("div");
                leftContainer = new HtmlGenericControl("div");

                ctrl = this.CreateApplicationLogo();
                if (ctrl != null)
                {
                    leftContainer.Controls.Add(ctrl);
                }

                ctrl = this.CreateLogo();
                if (ctrl != null)
                {
                    leftContainer.Controls.Add(ctrl);
                }

                if (m_MasterPage.VisibleSearchControl)
                {
                    ctrl = CreateSearchControl(null);

                    leftContainer.Controls.Add(ctrl);
                }

                if (leftContainer.HasControls())
                {
                    container.Controls.Add(leftContainer);
                }

                ctrl = this.CreateHeaderLinks();
                if (ctrl != null)
                {
                    container.Controls.Add(ctrl);
                }

                if (container.HasControls())
                {
                    container.Attributes["class"] = "container";

                    mainContainer = new HtmlGenericControl("div");
                    mainContainer.Attributes["class"] = "Mp_Hdr";
                    mainContainer.Controls.Add(container);

                    this.Controls.Add(mainContainer);
                }
            }
            finally
            {
                if (mainContainer != null)
                {
                    mainContainer.Dispose();
                }

                if (container != null)
                {
                    container.Dispose();
                }

                if (leftContainer != null)
                {
                    leftContainer.Dispose();
                }

                if (ctrl != null)
                {
                    ctrl.Dispose();
                }
            }
        }
示例#5
0
        protected void StartMenu_ItemDataBound(object sender, CommandEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            HtmlGenericControl li = sender as HtmlGenericControl;

            if (li == null)
            {
                return;
            }

            Micajah.Common.Bll.Action action = (Micajah.Common.Bll.Action)e.CommandArgument;

            if (string.IsNullOrEmpty(action.Name) || action.Description == "DispayAsWarningMessage")
            {
                li.Visible = false;
                return;
            }

            if (action.NavigateUrl == null)
            {
                if ((m_StartMenuCheckedItems != null) && m_StartMenuCheckedItems.Contains(action.ActionId))
                {
                    li.Attributes["class"] = "Cbc";
                    if (li.HasControls())
                    {
                        ((HyperLink)li.Controls[0]).NavigateUrl = (string.IsNullOrEmpty(action.AbsoluteNavigateUrl) ? action.CustomAbsoluteNavigateUrl : null);
                    }
                }
                else
                {
                    li.Attributes["class"] = "Cb";
                }
            }
            else if (!string.IsNullOrEmpty(action.NavigateUrl))
            {
                li.Attributes["class"] = "G";
                if (string.Compare(action.NavigateUrl, action.VideoUrl, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (li.Controls.Count > 0)
                    {
                        HyperLink link = (HyperLink)li.Controls[0];
                        link.NavigateUrl = string.Empty;

                        if (li.Controls.Count > 1)
                        {
                            HtmlGenericControl span = (HtmlGenericControl)li.Controls[1];
                            if (span.HasControls())
                            {
                                link      = (HyperLink)span.Controls[0];
                                link.Text = Resources.StartControl_WatchLink_Text;
                            }
                        }
                    }

                    return;
                }
            }

            if (!string.IsNullOrEmpty(action.VideoUrl))
            {
                if (li.Controls.Count > 1)
                {
                    HtmlGenericControl span = (HtmlGenericControl)li.Controls[1];
                    if (span.HasControls())
                    {
                        HyperLink link = (HyperLink)span.Controls[0];
                        link.Attributes["rel"] = "WatchVideo";
                    }
                }
            }
        }
示例#6
0
        /// <summary>
        /// Creates child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            HtmlGenericControl htmlContainer = null;

            try
            {
                m_MainContainer = new HtmlGenericControl("div");

                switch (m_Position)
                {
                case SubmenuPosition.Left:
                    int width     = FrameworkConfiguration.Current.WebApplication.MasterPage.LeftArea.Width;
                    int decrement = m_ModernTheme ? 40 : 8;
                    if (width > decrement)
                    {
                        width -= decrement;
                    }

                    m_MainContainer.Style[HtmlTextWriterStyle.Width] = width.ToString(CultureInfo.InvariantCulture) + "px";
                    m_MainContainer.Attributes["class"] = "Mp_L";

                    if ((this.Items != null) && (m_Items.Count > 0))
                    {
                        this.CreateLeftSubmenu();
                    }

                    if (m_MainContainer.HasControls())
                    {
                        if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.MasterPage.LeftArea.Html))
                        {
                            m_MainContainer.Controls.Add(new LiteralControl("<br /><br />"));

                            htmlContainer = new HtmlGenericControl("div");
                            htmlContainer.Attributes["class"] = "Mp_Lah";
                            htmlContainer.InnerHtml           = FrameworkConfiguration.Current.WebApplication.MasterPage.LeftArea.Html;
                            m_MainContainer.Controls.Add(htmlContainer);
                        }
                    }
                    break;

                case SubmenuPosition.Top:
                    if ((this.Items != null) && (m_Items.Count > 0))
                    {
                        this.CreateTopSubmenu();
                    }
                    break;
                }

                if (m_MainContainer.HasControls())
                {
                    this.Controls.Add(m_MainContainer);
                }
            }
            finally
            {
                if (htmlContainer != null)
                {
                    htmlContainer.Dispose();
                }
                if (m_MainContainer != null)
                {
                    m_MainContainer.Dispose();
                }
            }
        }