ButtonFieldBase.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / ButtonFieldBase.cs / 1305376 / ButtonFieldBase.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls { 
 
    using System;
    using System.Collections; 
    using System.ComponentModel;


    ///  
    /// Defines the base class for DataControlFields whose main purpose is to contain buttons for commands.
    ///  
    public abstract class ButtonFieldBase : DataControlField { 

 
        /// 
        /// Indicates the button type for the field.
        /// 
        [ 
        WebCategory("Appearance"),
        DefaultValue(ButtonType.Link), 
        WebSysDescription(SR.ButtonFieldBase_ButtonType) 
        ]
        public virtual ButtonType ButtonType { 
            get {
                object o = ViewState["ButtonType"];
                if (o != null)
                    return(ButtonType)o; 
                return ButtonType.Link;
            } 
            set { 
                if (value < ButtonType.Button || value > ButtonType.Link) {
                    throw new ArgumentOutOfRangeException("value"); 
                }
                object oldValue = ViewState["ButtonType"];
                if (oldValue == null || (ButtonType)oldValue != value) {
                    ViewState["ButtonType"] = value; 
                    OnFieldChanged();
                } 
            } 
        }
 

        [
        WebCategory("Behavior"),
        DefaultValue(false), 
        WebSysDescription(SR.ButtonFieldBase_CausesValidation)
        ] 
        public virtual bool CausesValidation { 
            get {
                object o = ViewState["CausesValidation"]; 
                if (o != null) {
                    return (bool)o;
                }
                return false; 
            }
            set { 
                object oldValue = ViewState["CausesValidation"]; 
                if (oldValue == null || (bool)oldValue != value) {
                    ViewState["CausesValidation"] = value; 
                    OnFieldChanged();
                }
            }
        } 

 
        [ 
        WebCategory("Behavior"),
        DefaultValue(false), 
        WebSysDescription(SR.DataControlField_ShowHeader)
        ]
        public override bool ShowHeader {
            get { 
                object o = ViewState["ShowHeader"];
                if (o != null) { 
                    return (bool)o; 
                }
                return false; 
            }
            set {
                object oldValue = ViewState["ShowHeader"];
                if (oldValue == null || (bool)oldValue != value) { 
                    ViewState["ShowHeader"] = value;
                    OnFieldChanged(); 
                } 
            }
        } 


        [
        WebCategory("Behavior"), 
        DefaultValue(""),
        WebSysDescription(SR.ButtonFieldBase_ValidationGroup) 
        ] 
        public virtual string ValidationGroup {
            get { 
                object o = ViewState["ValidationGroup"];
                if (o != null) {
                    return (string)o;
                } 
                return String.Empty;
            } 
            set { 
                if (!String.Equals(value, ViewState["ValidationGroup"])) {
                    ViewState["ValidationGroup"] = value; 
                    OnFieldChanged();
                }
            }
        } 

        protected override void CopyProperties(DataControlField newField) { 
            ((ButtonFieldBase)newField).ButtonType = ButtonType; 
            ((ButtonFieldBase)newField).CausesValidation = CausesValidation;
            ((ButtonFieldBase)newField).ValidationGroup = ValidationGroup; 
            base.CopyProperties(newField);
        }
    }
} 

 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls { 
 
    using System;
    using System.Collections; 
    using System.ComponentModel;


    ///  
    /// Defines the base class for DataControlFields whose main purpose is to contain buttons for commands.
    ///  
    public abstract class ButtonFieldBase : DataControlField { 

 
        /// 
        /// Indicates the button type for the field.
        /// 
        [ 
        WebCategory("Appearance"),
        DefaultValue(ButtonType.Link), 
        WebSysDescription(SR.ButtonFieldBase_ButtonType) 
        ]
        public virtual ButtonType ButtonType { 
            get {
                object o = ViewState["ButtonType"];
                if (o != null)
                    return(ButtonType)o; 
                return ButtonType.Link;
            } 
            set { 
                if (value < ButtonType.Button || value > ButtonType.Link) {
                    throw new ArgumentOutOfRangeException("value"); 
                }
                object oldValue = ViewState["ButtonType"];
                if (oldValue == null || (ButtonType)oldValue != value) {
                    ViewState["ButtonType"] = value; 
                    OnFieldChanged();
                } 
            } 
        }
 

        [
        WebCategory("Behavior"),
        DefaultValue(false), 
        WebSysDescription(SR.ButtonFieldBase_CausesValidation)
        ] 
        public virtual bool CausesValidation { 
            get {
                object o = ViewState["CausesValidation"]; 
                if (o != null) {
                    return (bool)o;
                }
                return false; 
            }
            set { 
                object oldValue = ViewState["CausesValidation"]; 
                if (oldValue == null || (bool)oldValue != value) {
                    ViewState["CausesValidation"] = value; 
                    OnFieldChanged();
                }
            }
        } 

 
        [ 
        WebCategory("Behavior"),
        DefaultValue(false), 
        WebSysDescription(SR.DataControlField_ShowHeader)
        ]
        public override bool ShowHeader {
            get { 
                object o = ViewState["ShowHeader"];
                if (o != null) { 
                    return (bool)o; 
                }
                return false; 
            }
            set {
                object oldValue = ViewState["ShowHeader"];
                if (oldValue == null || (bool)oldValue != value) { 
                    ViewState["ShowHeader"] = value;
                    OnFieldChanged(); 
                } 
            }
        } 


        [
        WebCategory("Behavior"), 
        DefaultValue(""),
        WebSysDescription(SR.ButtonFieldBase_ValidationGroup) 
        ] 
        public virtual string ValidationGroup {
            get { 
                object o = ViewState["ValidationGroup"];
                if (o != null) {
                    return (string)o;
                } 
                return String.Empty;
            } 
            set { 
                if (!String.Equals(value, ViewState["ValidationGroup"])) {
                    ViewState["ValidationGroup"] = value; 
                    OnFieldChanged();
                }
            }
        } 

        protected override void CopyProperties(DataControlField newField) { 
            ((ButtonFieldBase)newField).ButtonType = ButtonType; 
            ((ButtonFieldBase)newField).CausesValidation = CausesValidation;
            ((ButtonFieldBase)newField).ValidationGroup = ValidationGroup; 
            base.CopyProperties(newField);
        }
    }
} 

 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK