Example #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// OnPreRender runs when just before the Render phase of the Page Lifecycle
        /// </summary>
        /// -----------------------------------------------------------------------------
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (ModuleAction != null && ActionManager.IsVisible(ModuleAction))
            {
                Text            = ModuleAction.Title;
                CommandArgument = ModuleAction.ID.ToString();

                if (DisplayIcon && (!string.IsNullOrEmpty(ModuleAction.Icon) || !string.IsNullOrEmpty(ImageUrl)))
                {
                    if (!string.IsNullOrEmpty(ImageUrl))
                    {
                        ImageUrl = ModuleControl.ModuleContext.Configuration.ContainerPath.Substring(0, ModuleControl.ModuleContext.Configuration.ContainerPath.LastIndexOf("/") + 1) + ImageUrl;
                    }
                    else
                    {
                        if (ModuleAction.Icon.IndexOf("/") > Null.NullInteger)
                        {
                            ImageUrl = ModuleAction.Icon;
                        }
                        else
                        {
                            ImageUrl = "~/images/" + ModuleAction.Icon;
                        }
                    }
                }
                ActionManager.GetClientScriptURL(ModuleAction, this);
            }
            else
            {
                Visible = false;
            }
        }
Example #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// OnLoad runs when the control is loaded into the Control Tree
        /// </summary>
        /// <history>
        ///     [cnurse]	12/23/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            foreach (ModuleAction action in ModuleActions)
            {
                if (action != null && ActionManager.IsVisible(action))
                {
                    //Create a new ActionCommandButton
                    var actionButton = new ActionCommandButton();

                    //Set all the properties
                    actionButton.ModuleAction  = action;
                    actionButton.ModuleControl = ModuleControl;
                    actionButton.CommandName   = CommandName;
                    actionButton.CssClass      = CssClass;
                    actionButton.DisplayLink   = DisplayLink;
                    actionButton.DisplayIcon   = DisplayIcon;
                    actionButton.ImageUrl      = ImageURL;

                    //Add a handler for the Action Event
                    actionButton.Action += ActionButtonClick;

                    Controls.Add(actionButton);

                    Controls.Add(new LiteralControl(ButtonSeparator));
                }
            }
            Visible = (Controls.Count > 0);
        }