public static IDataControlButton CreateButton (ButtonType type, Control container, string text, string image, string command, string commandArg, bool allowCallback)
		{
			IDataControlButton btn;

			switch (type) {
			case ButtonType.Link:
				btn = new DataControlLinkButton ();
				break;
			case ButtonType.Image:
				btn = new DataControlImageButton ();
				btn.ImageUrl = image;
				break;
			default:
				btn = new DataControlButton ();
				break;
			}

			btn.Container = container;
			btn.CommandName = command;
			btn.CommandArgument = commandArg;
			btn.Text = text;
			btn.CausesValidation = false;
			btn.AllowCallback = allowCallback;

			return btn;
		}
Ejemplo n.º 2
0
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            string index = rowIndex.ToString();

            if (cellType == DataControlCellType.DataCell)
            {
                IDataControlButton btn = DataControlButton.CreateButton(ButtonType, Control, Text, ImageUrl, CommandName, index, false);

                if (CausesValidation)
                {
                    btn.Container        = null;
                    btn.CausesValidation = true;
                    btn.ValidationGroup  = ValidationGroup;
                }

                if (!String.IsNullOrEmpty(DataTextField))
                {
                    if ((rowState & DataControlRowState.Insert) == 0)
                    {
                        cell.DataBinding += new EventHandler(OnDataBindField);
                    }
                }
                cell.Controls.Add((Control)btn);
            }
            else
            {
                base.InitializeCell(cell, cellType, rowState, rowIndex);
            }
        }
Ejemplo n.º 3
0
 public virtual void InitializeCell(DataControlFieldCell cell,
                                    DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
 {
     if (cellType == DataControlCellType.Header)
     {
         if (HeaderText.Length > 0 && sortingEnabled && SortExpression.Length > 0)
         {
             cell.Controls.Add((Control)DataControlButton.CreateButton(String.IsNullOrEmpty(HeaderImageUrl) ? ButtonType.Link : ButtonType.Image, control, HeaderText, HeaderImageUrl, DataControlCommands.SortCommandName, SortExpression, true));
         }
         else if (HeaderImageUrl.Length > 0)
         {
             Image image = new Image();
             image.ImageUrl = HeaderImageUrl;
             cell.Controls.Add(image);
         }
         else
         {
             cell.Text = HeaderText.Length > 0 ? HeaderText : " ";
         }
     }
     else if (cellType == DataControlCellType.Footer)
     {
         string footerText = FooterText;
         cell.Text = (footerText.Length > 0) ? footerText : " ";
     }
 }
Ejemplo n.º 4
0
        public static IDataControlButton CreateButton(ButtonType type, Control container, string text, string image, string command, string commandArg, bool allowCallback)
        {
            IDataControlButton btn;

            switch (type)
            {
            case ButtonType.Link:
                btn = new DataControlLinkButton();
                break;

            case ButtonType.Image:
                btn          = new DataControlImageButton();
                btn.ImageUrl = image;
                break;

            default:
                btn = new DataControlButton();
                break;
            }

            btn.Container        = container;
            btn.CommandName      = command;
            btn.CommandArgument  = commandArg;
            btn.Text             = text;
            btn.CausesValidation = false;
            btn.AllowCallback    = allowCallback;

            return(btn);
        }
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl     control;
            IPostBackContainer container = base.Control as IPostBackContainer;
            bool flag = true;

            switch (this.ButtonType)
            {
            case ButtonType.Button:
                if ((container == null) || causesValidation)
                {
                    control = new Button();
                }
                else
                {
                    control = new DataControlButton(container);
                    flag    = false;
                }
                break;

            case ButtonType.Link:
                if ((container == null) || causesValidation)
                {
                    control = new DataControlLinkButton(null);
                }
                else
                {
                    control = new DataControlLinkButton(container);
                    flag    = false;
                }
                break;

            default:
                if ((container != null) && !causesValidation)
                {
                    control = new DataControlImageButton(container);
                    flag    = false;
                }
                else
                {
                    control = new ImageButton();
                }
                ((ImageButton)control).ImageUrl = imageUrl;
                break;
            }
            control.Text            = buttonText;
            control.CommandName     = commandName;
            control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (flag)
            {
                control.CausesValidation = causesValidation;
            }
            control.ValidationGroup = validationGroup;
            cell.Controls.Add((WebControl)control);
        }
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl control;
            IPostBackContainer container = base.Control as IPostBackContainer;
            bool flag = true;
            switch (this.ButtonType)
            {
                case ButtonType.Button:
                    if ((container == null) || causesValidation)
                    {
                        control = new Button();
                    }
                    else
                    {
                        control = new DataControlButton(container);
                        flag = false;
                    }
                    break;

                case ButtonType.Link:
                    if ((container == null) || causesValidation)
                    {
                        control = new DataControlLinkButton(null);
                    }
                    else
                    {
                        control = new DataControlLinkButton(container);
                        flag = false;
                    }
                    break;

                default:
                    if ((container != null) && !causesValidation)
                    {
                        control = new DataControlImageButton(container);
                        flag = false;
                    }
                    else
                    {
                        control = new ImageButton();
                    }
                    ((ImageButton) control).ImageUrl = imageUrl;
                    break;
            }
            control.Text = buttonText;
            control.CommandName = commandName;
            control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (flag)
            {
                control.CausesValidation = causesValidation;
            }
            control.ValidationGroup = validationGroup;
            cell.Controls.Add((WebControl) control);
        }
        Control CreateButton(string text, string image, string command, string arg)
        {
            IDataControlButton c = DataControlButton.CreateButton(ButtonType, Control, text, image, command, arg, false);

            if (CausesValidation)
            {
                if (command == DataControlCommands.UpdateCommandName || command == DataControlCommands.InsertCommandName)
                {
                    c.Container        = null;
                    c.CausesValidation = true;
                    c.ValidationGroup  = ValidationGroup;
                }
            }
            return((Control)c);
        }
Ejemplo n.º 8
0
        TableCell CreateCell(string text, string image, string command, string argument)
        {
            TableCell cell = new TableCell();

            Control button;

            if (String.IsNullOrEmpty(command))
            {
                Label l = new Label();
                l.Text = text;
                button = l;
            }
            else
            {
                button = (Control)DataControlButton.CreateButton(String.IsNullOrEmpty(image) ? ButtonType.Link : ButtonType.Image, ctrl, text, image, command, argument, true);
            }

            cell.Controls.Add(button);
            return(cell);
        }
Ejemplo n.º 9
0
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);
            if ((cellType != DataControlCellType.Header) && (cellType != DataControlCellType.Footer))
            {
                IButtonControl     control;
                IPostBackContainer container = base.Control as IPostBackContainer;
                bool causesValidation        = this.CausesValidation;
                bool flag2 = true;
                switch (this.ButtonType)
                {
                case ButtonType.Button:
                    if ((container == null) || causesValidation)
                    {
                        control = new Button();
                    }
                    else
                    {
                        control = new DataControlButton(container);
                        flag2   = false;
                    }
                    break;

                case ButtonType.Link:
                    if ((container == null) || causesValidation)
                    {
                        control = new DataControlLinkButton(null);
                    }
                    else
                    {
                        control = new DataControlLinkButton(container);
                        flag2   = false;
                    }
                    break;

                default:
                    if ((container != null) && !causesValidation)
                    {
                        control = new DataControlImageButton(container);
                        flag2   = false;
                    }
                    else
                    {
                        control = new ImageButton();
                    }
                    ((ImageButton)control).ImageUrl = this.ImageUrl;
                    break;
                }
                control.Text            = this.Text;
                control.CommandName     = this.CommandName;
                control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (flag2)
                {
                    control.CausesValidation = causesValidation;
                }
                control.ValidationGroup = this.ValidationGroup;
                if ((this.DataTextField.Length != 0) && base.Visible)
                {
                    ((WebControl)control).DataBinding += new EventHandler(this.OnDataBindField);
                }
                cell.Controls.Add((WebControl)control);
            }
        }
Ejemplo n.º 10
0
		Control CreateButton (string id, string command, ButtonType type, string text, string image, Style style)
		{
			DataControlButton b = new DataControlButton (this, text, image, command, "", false);
			b.ID = id;
			b.ButtonType = type;
			RegisterApplyStyle (b, NavigationButtonStyle);
			RegisterApplyStyle (b, style);
			return b;
		}
Ejemplo n.º 11
0
        private void AddButtonToCell(DataControlFieldCell cell, string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl)
        {
            IButtonControl     button;
            IPostBackContainer container = Control as IPostBackContainer;
            bool setCausesValidation     = true; // the setter on the DataControlButtons throw if there's a container for security

            switch (ButtonType)
            {
            case ButtonType.Link: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlLinkButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new DataControlLinkButton(null);
                }

                break;
            }

            case ButtonType.Button: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new Button();
                }

                break;
            }

            case ButtonType.Image:
            default: {
                if (container != null && !causesValidation)
                {
                    button = new DataControlImageButton(container);
                    setCausesValidation = false;
                }
                else
                {
                    button = new ImageButton();
                }

                ((ImageButton)button).ImageUrl = imageUrl;
                break;
            }
            }

            button.Text            = buttonText;
            button.CommandName     = commandName;
            button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (setCausesValidation)
            {
                button.CausesValidation = causesValidation;
            }
            button.ValidationGroup = validationGroup;

            cell.Controls.Add((WebControl)button);
        }
Ejemplo n.º 12
0
		DataControlButton CreateButton (string text, string image, string command, string arg)
		{
			DataControlButton c = new DataControlButton (Control, text, image, command, arg, false);
			c.CausesValidation = CausesValidation;
			return c;
		}
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);
            if ((cellType != DataControlCellType.Header) && (cellType != DataControlCellType.Footer))
            {
                IButtonControl control;
                IPostBackContainer container = base.Control as IPostBackContainer;
                bool causesValidation = this.CausesValidation;
                bool flag2 = true;
                switch (this.ButtonType)
                {
                    case ButtonType.Button:
                        if ((container == null) || causesValidation)
                        {
                            control = new Button();
                        }
                        else
                        {
                            control = new DataControlButton(container);
                            flag2 = false;
                        }
                        break;

                    case ButtonType.Link:
                        if ((container == null) || causesValidation)
                        {
                            control = new DataControlLinkButton(null);
                        }
                        else
                        {
                            control = new DataControlLinkButton(container);
                            flag2 = false;
                        }
                        break;

                    default:
                        if ((container != null) && !causesValidation)
                        {
                            control = new DataControlImageButton(container);
                            flag2 = false;
                        }
                        else
                        {
                            control = new ImageButton();
                        }
                        ((ImageButton) control).ImageUrl = this.ImageUrl;
                        break;
                }
                control.Text = this.Text;
                control.CommandName = this.CommandName;
                control.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (flag2)
                {
                    control.CausesValidation = causesValidation;
                }
                control.ValidationGroup = this.ValidationGroup;
                if ((this.DataTextField.Length != 0) && base.Visible)
                {
                    ((WebControl) control).DataBinding += new EventHandler(this.OnDataBindField);
                }
                cell.Controls.Add((WebControl) control);
            }
        }
Ejemplo n.º 14
0
		public override void InitializeCell (DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
		{
			string index = rowIndex.ToString ();
			
			if (cellType == DataControlCellType.DataCell) {
				DataControlButton btn = new DataControlButton (Control);
				btn.CommandName = CommandName;
				btn.CommandArgument = index;
				
				if (DataTextField != "") {
					if ((rowState & DataControlRowState.Insert) == 0)
						cell.DataBinding += new EventHandler (OnDataBindField);
				}
				else {
					btn.Text = Text;
					btn.ButtonType = ButtonType;
					if (ButtonType == ButtonType.Image) btn.ImageUrl = ImageUrl;
				}
				cell.Controls.Add (btn);
			}
			else
				base.InitializeCell (cell, cellType, rowState, rowIndex);
		}
Ejemplo n.º 15
0
        private void AddButtonToCell(DataControlFieldCell cell,  string commandName, string buttonText, bool causesValidation, string validationGroup, int rowIndex, string imageUrl) {
            IButtonControl button;
            IPostBackContainer container = Control as IPostBackContainer;
            bool setCausesValidation = true;    // the setter on the DataControlButtons throw if there's a container for security

            switch (ButtonType) {
                case ButtonType.Link: {
                    if (container != null && !causesValidation) {
                        button = new DataControlLinkButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new DataControlLinkButton(null);
                    }

                    break;
                }
                case ButtonType.Button: {
                    if (container != null && !causesValidation) {
                        button = new DataControlButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new Button();
                    }

                    break;
                }
                case ButtonType.Image:
                default: {
                    if (container != null && !causesValidation) {
                        button = new DataControlImageButton(container);
                        setCausesValidation = false;
                    }
                    else {
                        button = new ImageButton();
                    }

                    ((ImageButton)button).ImageUrl = imageUrl;
                    break;
                }
            }
            
            button.Text = buttonText;
            button.CommandName = commandName;
            button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
            if (setCausesValidation) {
                button.CausesValidation = causesValidation;
            }
            button.ValidationGroup = validationGroup;

            cell.Controls.Add((WebControl)button);

        }
Ejemplo n.º 16
0
        /// <devdoc>
        /// <para>Initializes a cell in the <see cref='System.Web.UI.WebControls.ButtonField'/> .</para>
        /// </devdoc>
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if ((cellType != DataControlCellType.Header) &&
                (cellType != DataControlCellType.Footer)) {
                IButtonControl button;
                IPostBackContainer container = Control as IPostBackContainer;
                bool causesValidation = CausesValidation;
                bool setCausesValidation = true;    // the setter on the DataControlButtons throw if there's a container for security

                switch(ButtonType) {
                    case ButtonType.Link: {
                        if (container != null && !causesValidation) {
                            button = new DataControlLinkButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            // use DataControlLinkButton because it uses the right forecolor
                            button = new DataControlLinkButton(null);
                        }
                        break;
                    }
                    case ButtonType.Button: {
                        if (container != null && !causesValidation) {
                            button = new DataControlButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            button = new Button();
                        }
                        break;
                    }
                    case ButtonType.Image:
                    default: {
                        if (container != null && !causesValidation) {
                            button = new DataControlImageButton(container);
                            setCausesValidation = false;
                        }
                        else {
                            button = new ImageButton();
                        }

                        ((ImageButton)button).ImageUrl = ImageUrl;
                        break;
                    }
                }

                button.Text = Text;
                button.CommandName = CommandName;
                button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (setCausesValidation) {
                    button.CausesValidation = causesValidation;
                }
                button.ValidationGroup = ValidationGroup;
                
                if (DataTextField.Length != 0 && Visible) {
                    ((WebControl)button).DataBinding += new EventHandler(this.OnDataBindField);
                }

                cell.Controls.Add((WebControl)button);
            }
        }
Ejemplo n.º 17
0
        /// <devdoc>
        /// <para>Initializes a cell in the <see cref='System.Web.UI.WebControls.ButtonField'/> .</para>
        /// </devdoc>
        public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if ((cellType != DataControlCellType.Header) &&
                (cellType != DataControlCellType.Footer))
            {
                IButtonControl     button;
                IPostBackContainer container = Control as IPostBackContainer;
                bool causesValidation        = CausesValidation;
                bool setCausesValidation     = true; // the setter on the DataControlButtons throw if there's a container for security

                switch (ButtonType)
                {
                case ButtonType.Link: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlLinkButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        // use DataControlLinkButton because it uses the right forecolor
                        button = new DataControlLinkButton(null);
                    }
                    break;
                }

                case ButtonType.Button: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        button = new Button();
                    }
                    break;
                }

                case ButtonType.Image:
                default: {
                    if (container != null && !causesValidation)
                    {
                        button = new DataControlImageButton(container);
                        setCausesValidation = false;
                    }
                    else
                    {
                        button = new ImageButton();
                    }

                    ((ImageButton)button).ImageUrl = ImageUrl;
                    break;
                }
                }

                button.Text            = Text;
                button.CommandName     = CommandName;
                button.CommandArgument = rowIndex.ToString(CultureInfo.InvariantCulture);
                if (setCausesValidation)
                {
                    button.CausesValidation = causesValidation;
                }
                button.ValidationGroup = ValidationGroup;

                if (DataTextField.Length != 0 && Visible)
                {
                    ((WebControl)button).DataBinding += new EventHandler(this.OnDataBindField);
                }

                cell.Controls.Add((WebControl)button);
            }
        }