Beispiel #1
0
        /// <summary>
        /// Renders the Element as a Disabled If Control
        /// </summary>
        /// <param name="modelExpression">The model expression.</param>
        /// <param name="targetValue">The target value.</param>
        /// <param name="conditionType">Type of the comparison.</param>
        /// <returns></returns>
        protected TBuilder AsDisabledIf <TProperty>(Expression <Func <TModel, TProperty> > modelExpression,
                                                    object targetValue,
                                                    JSConditionTypes conditionType = JSConditionTypes.IsEqualToValue)
        {
            AsDisabled(CheckCondition(modelExpression, targetValue, conditionType));

            string disabledIfKey = AddConditionDataAttributes(modelExpression, targetValue, conditionType);

            disabledIfConditionKeys.Add(disabledIfKey);

            return((TBuilder)this);
        }
Beispiel #2
0
        private string AddConditionDataAttributes <TProperty>(Expression <Func <TModel, TProperty> > modelExpression,
                                                              object targetValue,
                                                              JSConditionTypes conditionType)
        {
            string conditionKey = GenerateConditionKey();

            WithDataAttribute(String.Format("condition-target-name-k{0}", conditionKey), MvcHelper.Current.GetPropertyName(helper, modelExpression));
            WithDataAttribute(String.Format("condition-target-value-k{0}", conditionKey), targetValue);
            WithDataAttribute(String.Format("condition-type-k{0}", conditionKey), (int)conditionType);

            return(conditionKey);
        }
Beispiel #3
0
        /// <summary>
        /// Renders the Element as a Hidden If Control
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="modelExpression">The model expression.</param>
        /// <param name="targetValue">The target value.</param>
        /// <param name="conditionType">Type of the condition.</param>
        /// <returns></returns>
        public TBuilder AsHiddenIf <TProperty>(Expression <Func <TModel, TProperty> > modelExpression,
                                               object targetValue,
                                               JSConditionTypes conditionType = JSConditionTypes.IsEqualToValue)
        {
            AsHidden(CheckCondition(modelExpression, targetValue, conditionType));

            string hiddenIfKey = AddConditionDataAttributes(modelExpression, targetValue, conditionType);

            hiddenIfConditionKeys.Add(hiddenIfKey);

            return((TBuilder)this);
        }
Beispiel #4
0
        private bool CheckCondition <TProperty>(Expression <Func <TModel, TProperty> > modelExpression,
                                                object targetValue,
                                                JSConditionTypes comparisonType)
        {
            switch (comparisonType)
            {
            case JSConditionTypes.IsNotEqualToValue:

                return(MvcHelper.Current.GetPropertyValue(helper, modelExpression).ToString() != targetValue.ToString());

            case JSConditionTypes.ValidationEqualsValue:

                return(MvcHelper.Current.ExpressionHasErrors(helper, modelExpression) != (bool)targetValue);

            case JSConditionTypes.IsEqualToValue:
            default:

                return(MvcHelper.Current.GetPropertyValue(helper, modelExpression).ToString() == targetValue.ToString());
            }
        }
Beispiel #5
0
 /// <summary>
 /// Renders the Button as Disabled if a Condition Is Met
 /// </summary>
 /// <param name="modelExpression">The model expression.</param>
 /// <param name="targetValue">The target value.</param>
 /// <param name="conditionType">Type of the comparison.</param>
 /// <returns></returns>
 public new TBuilder AsDisabledIf <TProperty>(Expression <Func <TModel, TProperty> > modelExpression,
                                              object targetValue,
                                              JSConditionTypes conditionType = JSConditionTypes.IsEqualToValue)
 {
     return(base.AsDisabledIf(modelExpression, targetValue, conditionType));
 }