private void CreateControlLayout()
        {
            Dictionary <string, string> entityMapping = (Dictionary <string, string>)SessionManager.GetSessionValueNoRedirect(this.Page, SessionStrings.ENTITY_MAPPING);
            string catalogueName = entityMapping[Entity.GetType().Name].Replace("Catalogue", "");

            Page.Title = (!_EditMode) ? "Add " + catalogueName : "Edit " + catalogueName;

            lblTitle          = new IndLabel();
            lblTitle.CssClass = CSSStrings.TitleLabelCssClass;
            lblTitle.Text     = Page.Title;

            SetTextBoxesStates();

            btnSave.ID = "SaveButton";
            btnSave.Attributes.Add("OnClick", "return ClearOnBeforeUnload();");
            btnSave.ToolTip = "Save";
            //btnSave.CssClass = "SaveButton";
            btnSave.ImageUrl     = "~/Images/button_save.png";
            btnSave.ImageUrlOver = "~/Images/button_save.png";
            btnSave.Click       += new ImageClickEventHandler(btnSave_Click);

            btnCancel.ID = "CancelButton";
            btnCancel.CausesValidation = false;
            btnCancel.Attributes.Add("OnClick", "CheckDirty();");
            btnCancel.Attributes.Add("class", "CancelButton");
            btnCancel.Attributes.Add("title", "Cancel");
            btnCancel.Attributes.Add("type", "button");
        }
        /// <summary>
        /// Adds the corresponding validators to the currentControl
        /// </summary>
        /// <param name="entityProperty">the property mapped to the control</param>
        /// <param name="currentControl">the control to which the validators are added</param>
        private void AddValidators(PropertyInfo entityProperty, Control currentControl)
        {
            object[] validationAttributes;
            //Get the validation attributes of the property
            validationAttributes = entityProperty.GetCustomAttributes(typeof(PropertyValidationAttribute), false);
            if (validationAttributes.Length == 1)
            {
                PropertyValidationAttribute validationAttribute = (PropertyValidationAttribute)validationAttributes[0];

                IndLabel lblRequired = new IndLabel();
                lblRequired.Text = " *";
                //If the property is required, add a RequiredFieldValidator
                if (validationAttribute.IsRequired)
                {
                    lblRequired.ForeColor = System.Drawing.Color.Yellow;

                    if (currentControl is IndCatYearMonth)
                    {
                        ((IndCatYearMonth)currentControl).AddValidators(GetPropertyName(entityProperty));
                    }
                    else
                    {
                        //RequiredFieldValidator
                        RequiredFieldValidator requiredValidator = new RequiredFieldValidator();
                        requiredValidator.ID = "RequiredValidator" + currentControl.UniqueID;
                        requiredValidator.ControlToValidate = currentControl.ID;
                        if (currentControl is IndDatePicker)
                        {
                            requiredValidator.InitialValue = ApplicationConstants.MIN_DATE_CATALOGS;
                        }
                        requiredValidator.Display      = ValidatorDisplay.Dynamic;
                        requiredValidator.Text         = "*";
                        requiredValidator.ForeColor    = IndConstants.ColorValidator;
                        requiredValidator.ErrorMessage = GetPropertyName(entityProperty) + " is required.";
                        this.Controls.AddAt(this.Controls.IndexOf(currentControl) + 1, requiredValidator);
                    }
                }
                else
                {
                    lblRequired.ForeColor = IndConstants.ColorValidator;
                }
                this.Controls.AddAt(this.Controls.IndexOf(currentControl), lblRequired);

                //If the property must be in a range, add a RangeValidator
                if (validationAttribute.MinValue != int.MaxValue || validationAttribute.MaxValue != int.MinValue)
                {
                    //RangeValidator
                    RangeValidator rangeValidator = new RangeValidator();
                    rangeValidator.ID = "RangeValidator" + currentControl.UniqueID;
                    rangeValidator.ControlToValidate = currentControl.ID;
                    rangeValidator.MinimumValue      = validationAttribute.MinValue.ToString();
                    rangeValidator.MaximumValue      = validationAttribute.MaxValue.ToString();
                    rangeValidator.Type = ValidationDataType.Integer;
                    if (entityProperty.PropertyType == typeof(double) || entityProperty.PropertyType == typeof(decimal))
                    {
                        rangeValidator.Type = ValidationDataType.Double;
                    }
                    rangeValidator.Display      = ValidatorDisplay.Dynamic;
                    rangeValidator.Text         = "*";
                    rangeValidator.ForeColor    = IndConstants.ColorValidator;
                    rangeValidator.ErrorMessage = "Field " + GetPropertyName(entityProperty) + " not in the correct range (" + rangeValidator.MinimumValue + ", " + rangeValidator.MaximumValue + ").";
                    this.Controls.AddAt(this.Controls.IndexOf(currentControl) + 1, rangeValidator);
                }
                //If the property has a maximum length, add a RegularExpressionValidator
                if (validationAttribute.MaxLength != int.MinValue)
                {
                    if (currentControl is IndTextBox)
                    {
                        ((IndTextBox)currentControl).MaxLength = validationAttribute.MaxLength;
                    }
                    //RegularExpressionValidator
                    RegularExpressionValidator regValidator = new RegularExpressionValidator();
                    regValidator.ID = "RegValidator" + currentControl.UniqueID;
                    regValidator.ControlToValidate = currentControl.ID;
                    //Set the regular expression
                    regValidator.ValidationExpression = ".{0," + validationAttribute.MaxLength + "}";
                    regValidator.Display      = ValidatorDisplay.Dynamic;
                    regValidator.Text         = "*";
                    regValidator.ForeColor    = IndConstants.ColorValidator;
                    regValidator.ErrorMessage = "Field " + GetPropertyName(entityProperty) + " exceeds maximum allowed length (" + validationAttribute.MaxLength + " character(s)).";
                    this.Controls.AddAt(this.Controls.IndexOf(currentControl) + 1, regValidator);
                }
            }
            else //We do not have a validation attribute
            {
                //Put a invisible label in front of the control
                IndLabel lblRequired = new IndLabel();
                lblRequired.Text      = " *";
                lblRequired.ForeColor = IndConstants.ColorValidator;
                this.Controls.AddAt(this.Controls.IndexOf(currentControl), lblRequired);
            }
        }