Subclassed ASPxTextBox and error messages ...


Author
Message
Charles Thomas Blankenship...
Charles Thomas Blankenship
Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
I've successfully subclassed an ASPxTextBox to work with StrataFrame using the following code ... it works quite well.  The only problem I'm having is this, what code do I have to add in order to get that red arrow to appear next to it when a broken rule has been added for the field associated with it.  See attached:

https://drive.google.com/file/d/0BzuGM0X0_h52bFF4WlN3VnpmeE0/view?usp=sharing


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using DevExpress.Web.ASPxEditors;
using MicroFour.StrataFrame.Business;
using MicroFour.StrataFrame.UI;
using MicroFour.StrataFrame.UI.Web;
using MicroFour.StrataFrame.Extensibility;

namespace Crucible.Web.DevExStrataFrame
{
    [ToolboxData("<{0}:sfASPxTextBox ID=sfASPxTextBox runat=server></{0}:sfASPxTextBox>")]
    public class sfASPxTextBox: ASPxTextBox, IWebBusinessBindable
    {

        #region " Privates "

        private string _BindingField = "";
        private string _BindingProperty = "Text";
        private string _BindingFormat = "";
        private string _BusinessObjectName = "";
        private BindingDirections _BindingDirection = BindingDirections.TwoWay;
        private string _ErrorMessage = "";
        private bool _InError = false;
        private bool _IgnoreManageUIReadOnlyState = false;

        #endregion

        #region " Public Properties "

        /// <summary>
        /// The field on the business object to which this control is bound
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Category(BusinessMod.EDITOR_CATEGORY),
        DefaultValue(""),
        Description(BusinessMod.EDITOR_BINDINGFIELD_DESC),
        Editor(Constants.TE_WebBindingFieldTypeEditor, typeof(System.Drawing.Design.UITypeEditor))]
        public string BindingField
        {
            get { return _BindingField; }
            set { _BindingField = value; }
        }

        /// <summary>
        /// The property on the control that is bound to the data on the business object
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Category(BusinessMod.EDITOR_CATEGORY),
        DefaultValue("Text"),
        Description(BusinessMod.EDITOR_BINDINGPROPERTY_DESC),
        Editor(Constants.TE_BindingPropertyEditor, typeof(System.Drawing.Design.UITypeEditor))]
        public string BindingProperty
        {
            get { return _BindingProperty; }
            set { _BindingProperty = value; }
        }

        /// <summary>
        /// The format to display the data when the data is bound to the control.
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Description(BusinessMod.EDITOR_WEBBINDINGFORMAT_DESC),
        Category(BusinessMod.EDITOR_CATEGORY),
        DefaultValue("")]
        public string BindingFormat
        {
            get { return _BindingFormat; }
            set { _BindingFormat = value; }
        }

        /// <summary>
        /// The name of the business object on the page to which this control is bound
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Category(BusinessMod.EDITOR_CATEGORY),
        DefaultValue(""),
        Description(BusinessMod.EDITOR_BUSINESSOBJECT_DESC),
        Editor(Constants.TE_BusinessObjectNameTypeEditor, typeof(System.Drawing.Design.UITypeEditor))]
        public string BusinessObjectName
        {
            get { return _BusinessObjectName; }
            set { _BusinessObjectName = value; }
        }

        /// <summary>
        /// Determines whether or not the control's state is automatically managed by the business object
        /// to which it is bound
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Description(BusinessMod.EDITOR_IGNOREMANAGE_DESC),
        Category(BusinessMod.EDITOR_CATEGORY),
        DefaultValue(false)]
        public bool IgnoreManageUIReadOnlyState
        {
            get { return _IgnoreManageUIReadOnlyState; }
            set { _IgnoreManageUIReadOnlyState = value; }
        }

        /// <summary>
        /// Specified whether the data is bound from the control to the data, vice versa, or both.
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Category(BusinessMod.EDITOR_CATEGORY),
        Description(BusinessMod.EDITOR_WEBBINDINGDIRECTION_DESC)]
        public BindingDirections BindingDirection
        {
            get { return _BindingDirection; }
            set { _BindingDirection = value; }
        }
        #endregion

        #region " Non-Browsable Properties "

        /// <summary>
        /// Determines if the control is editable by the user (wraps Control.Enabled)
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Browsable(false),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool BindingEditable
        {
            get { return this.Enabled; }
            set { this.Enabled = value; }
        }

        /// <summary>
        /// The error message that is displayed when the control is in error
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Browsable(false),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public string ErrorMessage
        {
            get { return _ErrorMessage; }
            set { _ErrorMessage = value; }
        }

        /// <summary>
        /// Determines if the control is in error and the error provider should be displayed
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Browsable(false),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool InError
        {
            get { return _InError; }
            set { _InError = value; }
        }

        /// <summary>
        /// Determines whether or not the control has bindings that are in addition to the primary data binding
        /// </summary>
        /// <value></value>
        /// <remarks></remarks>
        [Browsable(false)]
        public bool HasAdditionalBindings
        {
            get { return false; }
        }
        #endregion
    }



}


Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Charles Thomas Blankenship...
Charles Thomas Blankenship
Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)Advanced StrataFrame User (640 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Ben nailed it ... here is the solution:

    protected override void Render(System.Web.UI.HtmlTextWriter writer) {
        
base.Render(writer);
        if 
(_InError) {
            writer.Write(BrokenRuleRenderer.RenderBrokenRule(
this));
            
writer.Flush();
        
}
    }


Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search