/// <summary> /// Generates an input password element with a javascript that prevents /// chars other than numbers from being entered. /// <para> /// The value is extracted from the target (if available) /// </para> /// <para> /// You can optionally pass an <c>exceptions</c> value through the dictionary. /// It must be a comma separated list of chars that can be accepted on the field. /// For example: /// </para> /// <code> /// FormHelper.NumberField("product.price", {exceptions='13,10,11'}) /// </code> /// In this case the key codes 13, 10 and 11 will be accepted on the field. /// <para> /// You can aslo optionally pass an <c>forbid</c> value through the dictionary. /// It must be a comma separated list of chars that cannot be accepted on the field. /// For example: /// </para> /// <code> /// FormHelper.NumberField("product.price", {forbid='46'}) /// </code> /// In this case the key code 46 (period) will not be accepted on the field. /// </summary> /// <param name="target">The object to get the value from and to be based on to create the element name.</param> /// <param name="attributes">Attributes for the FormHelper method and for the html element it generates</param> /// <param name="valueBehaviour">The value behaviour which defines whether the <c>value</c> attribute /// will be filled from the target.</param> /// <returns>The generated form element</returns> /// <remarks> /// You must invoke <see cref="FormHelper.InstallScripts"/> before using it /// </remarks> public virtual string PasswordNumberField(string target, IDictionary attributes, ValueBehaviour valueBehaviour) { target = RewriteTargetIfWithinObjectScope(target); var value = ObtainValue(target, attributes); switch (valueBehaviour) { case ValueBehaviour.Set: value = ObtainValue(target); break; case ValueBehaviour.DoNotSet: value = string.Empty; break; default: throw new ArgumentOutOfRangeException("valueBehaviour"); } attributes = attributes ?? new Hashtable(); ApplyNumberOnlyOptions(attributes); ApplyValidation(InputElementType.Text, target, ref attributes); return CreateInputElement("password", target, value, attributes); }
public static string PasswordNumberField(this FormHelper helper, System.String target, System.Object attributes, ValueBehaviour valueBehaviour) { return(helper.PasswordNumberField(target, new ModelDictionary(attributes), valueBehaviour)); }
/// <summary> /// Generates an input password element with a javascript that prevents /// chars other than numbers from being entered. /// <para> /// The value is extracted from the target (if available) /// </para> /// </summary> /// <param name="target">The object to get the value from and to be based on to create the element name.</param> /// <param name="valueBehaviour">The value behaviour which defines whether the <c>value</c> attribute /// will be filled from the target.</param> /// <returns>The generated form element</returns> /// <remarks> /// You must invoke <see cref="FormHelper.InstallScripts"/> before using it /// </remarks> public virtual string PasswordNumberField(string target, ValueBehaviour valueBehaviour) { return PasswordNumberField(target, null, valueBehaviour); }
public static string PasswordNumberField(this FormHelper helper, System.String target, System.Object attributes, ValueBehaviour valueBehaviour) { return helper.PasswordNumberField(target, new ModelDictionary(attributes), valueBehaviour); }