/// <summary> /// HTML Helper for Money RichField. /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name=DisplayFormat"> /// Optional: format to override the default two decimal /// digit display. This way same class can be used to /// display 4-digit decimal cents. /// </param> /// <param name="expression">Value expression supplied</param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfEditMoneyFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string DisplayFormat = DEFAULT_FMT, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); config.InputType = "text"; config.InputClass = "rf-money rounded-right"; config.ScrubType = "number"; config.InitialDisplayValue = string.Format("{0:" + DisplayFormat + "}", config.Value); config.PrependTextTag("$").ToString(); var inputTag = config.InputTag(); // Use the appropriate on-screen keyboard for mobile browsers inputTag.Attributes.Add("inputmode", "decimal"); inputTag.Attributes.Add("pattern", "-?[0-9]*.[0-9]*"); config.OriginalTag(); config.ScrubbedTag(); return(config.GetHtmlString()); }
/// <summary> /// HTML Helper for Date RichField. /// Depends on the jqueryUI Datepicker widget /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name="expression">Value expression supplied</param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfDateFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); string value = config.Value == null ? "" : string.Format("{0:M/d/yy}", config.Value); config.InputType = "text"; config.InputClass = "rf-date rounded-right apply-datepicker"; config.ScrubType = ""; config.InitialDisplayValue = value; config.InitialScrubbedValue = value; var inputTag = config.InputTag(); inputTag.Attributes.Add("placeholder", "mm/dd/yy"); config.OriginalTag(); config.ScrubbedTag(); return(config.GetHtmlString()); }
/// <summary> /// HTML Helper for Int RichField /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name="expression">Value expression supplied</param> /// <param name="DisplayFormat"> /// Optional: if supplied overrides the default format. /// </param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfEditIntFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string DisplayFormat = DEFAULT_FMT, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); config.InputType = "text"; config.InputClass = "rf-int rounded-right"; config.ScrubType = "number"; config.InitialDisplayValue = string.Format("{0:" + DisplayFormat + "}", config.Value); var inputTag = config.InputTag(); // display the proper keyboard on mobile browsers inputTag.Attributes.Add("inputmode", "numeric"); inputTag.Attributes.Add("pattern", "[,0-9]*"); config.OriginalTag(); config.ScrubbedTag(); return(config.GetHtmlString()); }
/// <summary> /// HTML Helper for Text RichField. /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name="expression">Value expression supplied</param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfEditTextFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); config.InputType = "text"; config.InputClass = "rf-text rounded-right"; config.InitialDisplayValue = config.InitialScrubbedValue; var inputTag = config.InputTag(); config.OriginalTag(); config.ScrubbedTag(); return(config.GetHtmlString()); }
/// <summary> /// HTML Helper for Percent RichField. /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name="expression">Value expression supplied</param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfEditPercentFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); config.InputType = "text"; config.InputClass = "rf-percent"; config.ScrubType = "number"; config.InitialDisplayValue = config.Value.ToString(); var inputTag = config.InputTag(); config.AppendTextTag("%"); config.OriginalTag(); config.ScrubbedTag(); return(config.GetHtmlString()); }
/// <summary> /// HTML Helper for the MonthYear RichField. /// User enters data via a select for the month /// and an input for the year. They are combined in to the /// scrubbed input for submission to the server. /// </summary> /// /// <typeparam name="TModel">Type of the model</typeparam> /// <typeparam name="TValue">Type of the value</typeparam> /// <param name="helper">HTML Helper</param> /// <param name="expression">Value expression supplied</param> /// <param name="htmlAttributes"> /// optional object specifying HTML attributes to append /// </param> /// <returns>The html to inject in the razor page.</returns> public static MvcHtmlString rfEditMonthYearFor <TModel, TValue>( this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object htmlAttributes = null) { var config = new FieldConfig <TModel, TValue>(helper, expression, htmlAttributes); config.InitialScrubbedValue = config.Value.ToString(); TagBuilder tag = config.Tag; TagBuilder monthTag = config.MonthSelectTag(config.Value as DateTime?); tag.InnerHtml += monthTag.ToString(); tag.InnerHtml += config.YearSelectTag(config.Value as DateTime?); var scrubbedTag = config.ScrubbedTag(); tag.InnerHtml += scrubbedTag.ToString(); return(new MvcHtmlString(tag.ToString())); }