Beispiel #1
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a copy of this instance.</returns>
        public override object Clone()
        {
            ToolbarButton copy = (ToolbarButton)base.Clone();

            copy.ButtonClick = this.ButtonClick;

            copy._HoverStyle    = (CssCollection)this._HoverStyle.Clone();
            copy._SelectedStyle = (CssCollection)this._SelectedStyle.Clone();

            return(copy);
        }
        /// <summary>
        /// Called when the Add Button menu item is clicked.
        /// </summary>
        /// <param name="sender">The source object</param>
        /// <param name="e">Event arguments</param>
        private void OnAddButton(object sender, EventArgs e)
        {
            Toolbar tbar = (Toolbar)Component;
            PropertyDescriptor itemsDesc = DesignUtil.GetPropertyDescriptor(tbar, "Items");
            if (itemsDesc != null)
            {
                // Tell the designer that we're changing the property
                RaiseComponentChanging(itemsDesc);

                // Do the change
                ToolbarButton btn = new ToolbarButton();
                btn.Text = "Button";
                tbar.Items.Add(btn);

                // Tell the designer that we've changed the property
                RaiseComponentChanged(itemsDesc, null, null);
                UpdateDesignTimeHtml();
            }
        }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Label lblTitle = (Label)Master.FindControl("lblTitle");
            if (lblTitle != null)
            {
                lblTitle.Text = ConfigurationManager.AppSettings["AppName"].ToString() + "User Management";
            }

            User user = new User(ConfigurationManager.AppSettings["connString"].ToString());
            this.lstUserProfile.DataSource     = user.getUserProfiles();
            this.lstUserProfile.DataTextField  = "ProfileName";
            this.lstUserProfile.DataValueField = "ProfileId";
            this.lstUserProfile.DataBind();

            Microsoft.Web.UI.WebControls.ToolbarButton newUser = new Microsoft.Web.UI.WebControls.ToolbarButton();
            newUser.Text    = "<span onclick=\"javascript:return newuser();\"><IMG src='../Images/create.jpg'></span>";
            newUser.ID      = "NEWUSER";
            newUser.ToolTip = "New User";
            toolUser.Items.Add(newUser);

            Microsoft.Web.UI.WebControls.ToolbarButton dltUser = new Microsoft.Web.UI.WebControls.ToolbarButton();
            dltUser.Text    = "<span onclick=\"javascript:return dltuser();\";><IMG src='../Images/delete.jpg'></span>";
            dltUser.ID      = "DLTUSER";
            dltUser.ToolTip = "Remove User";
            toolUser.Items.Add(dltUser);

            Microsoft.Web.UI.WebControls.ToolbarButton saveUser = new Microsoft.Web.UI.WebControls.ToolbarButton();
            saveUser.Text    = "<span onclick=\"javascript:return saveuser();\";><IMG src='../Images/save.jpg'></span>";
            saveUser.ID      = "SAVUSER";
            saveUser.ToolTip = "Save User";
            toolUser.Items.Add(saveUser);

            this.firstbutton.ImageUrl = ConfigurationManager.AppSettings["ImagePath"].ToString() + "first.gif";
            this.LastButton.ImageUrl  = ConfigurationManager.AppSettings["ImagePath"].ToString() + "last.gif";
            this.NextButton.ImageUrl  = ConfigurationManager.AppSettings["ImagePath"].ToString() + "next.gif";
            this.PrevButton.ImageUrl  = ConfigurationManager.AppSettings["ImagePath"].ToString() + "previous.gif";

            this.btnSearch.ImageUrl = ConfigurationManager.AppSettings["ImagePath"].ToString() + "go.jpg";

            //LoadNavSubGrid();
        }
        else
        {
            if (Request["h_Action"] != null)
            {
                if (Request["h_Action"] == "SAVE")
                {
                    if (this.txtUserId.Text == "(new)")
                    {
                        insertUser();
                    }
                    else
                    {
                        saveUser();
                    }
                }
                else if (Request["h_Action"] == "DELETE")
                {
                    deleteUser();
                }
            }
        }

        ClientScript.RegisterHiddenField("h_Action", "");
    }
Beispiel #4
0
        /// <summary>
        /// Raises the DataBinding event. This notifies a control to perform any data binding logic that is associated with it.
        /// </summary>
        /// <param name="e">An EventArgs object that contains the event data.</param>
        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            if (_DataSource != null)
            {
                Items.Clear();
                _ClearChildViewState = true;

                string            szCurGroup = String.Empty;
                ToolbarCheckGroup group      = null;

                foreach (Object dataItem in _DataSource)
                {
                    String type      = null;
                    String text      = null;
                    String imageUrl  = null;
                    String selected  = null;
                    String groupname = null;

                    if (DataTypeField != String.Empty)
                    {
                        type = DataBinder.GetPropertyValue(dataItem, DataTypeField, null);
                    }
                    if (DataTextField != String.Empty)
                    {
                        text = DataBinder.GetPropertyValue(dataItem, DataTextField, null);
                    }
                    if (DataImageUrlField != String.Empty)
                    {
                        imageUrl = DataBinder.GetPropertyValue(dataItem, DataImageUrlField, null);
                    }
                    if (DataSelectedField != String.Empty)
                    {
                        selected = DataBinder.GetPropertyValue(dataItem, DataSelectedField, null);
                    }
                    if (DataGroupnameField != String.Empty)
                    {
                        groupname = DataBinder.GetPropertyValue(dataItem, DataGroupnameField, null);
                    }

                    ToolbarItem item = MakeToolbarItem(type);

                    if (item == null)
                    {
                        continue;
                    }

                    bool bEndPrevGroup = (group != null);
                    bool bMakeNewGroup = false;

                    if (item is ToolbarCheckButton)
                    {
                        bEndPrevGroup =
                            (group != null) &&
                            ((groupname == null) || (groupname != szCurGroup));
                        bMakeNewGroup = ((groupname != null) && (groupname != szCurGroup));
                    }

                    if (bEndPrevGroup)
                    {
                        group      = null;
                        szCurGroup = String.Empty;
                    }

                    if (bMakeNewGroup)
                    {
                        group = new ToolbarCheckGroup();
                        Items.Add(group);
                        szCurGroup = groupname;
                    }

                    if (group != null)
                    {
                        group.Items.Add((ToolbarCheckButton)item);
                    }
                    else
                    {
                        Items.Add(item);
                    }

                    if (item is ToolbarButton)
                    {
                        ToolbarButton btn = (ToolbarButton)item;
                        if (text != null)
                        {
                            btn.Text = text;
                        }
                        if (imageUrl != null)
                        {
                            btn.ImageUrl = imageUrl;
                        }
                    }

                    if (item is ToolbarLabel)
                    {
                        ToolbarLabel label = (ToolbarLabel)item;
                        if (text != null)
                        {
                            label.Text = text;
                        }
                        if (imageUrl != null)
                        {
                            label.ImageUrl = imageUrl;
                        }
                    }

                    if (item is ToolbarCheckButton)
                    {
                        ToolbarCheckButton btn = (ToolbarCheckButton)item;
                        if (selected != null)
                        {
                            btn.SetSelected(selected.ToLower() == "true");
                        }
                    }
                }
            }
        }