/// <summary> /// Returns an <input> element of type "text" for the specified <paramref name="expression" />. /// </summary> /// <param name="htmlHelper">The <see cref="T:Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper" /> instance this method extends.</param> /// <param name="expression">Expression name, relative to the current model.</param> /// <param name="value">If non-<c>null</c>, value to include in the element.</param> /// <param name="htmlAttributes"> /// An <see cref="T:System.Object" /> that contains the HTML attributes for the element. Alternatively, an /// <see cref="T:System.Collections.Generic.IDictionary`2" /> instance containing the HTML /// attributes. /// </param> /// <param name="configAction">Action that implements text input configuration.</param> /// <returns>Text input html markup.</returns> /// <remarks> /// <para> /// Combines <see cref="P:Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo.HtmlFieldPrefix" /> and <paramref name="expression" /> to set /// <input> element's "name" attribute. Sanitizes <paramref name="expression" /> to set element's "id" /// attribute. /// </para> /// <para>Determines <input> element's "value" attribute based on the following precedence:</para> /// <list type="number"> /// <item> /// <see cref="T:Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary" /> entry for <paramref name="expression" /> (converted to a /// fully-qualified name) if entry exists and can be converted to a <see cref="T:System.String" />. /// </item> /// <item> /// <paramref name="value" /> if non-<c>null</c>. /// </item> /// <item> /// <see cref="T:Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary" /> entry for <paramref name="expression" /> (converted to a /// fully-qualified name) if entry exists and can be converted to a <see cref="T:System.String" />. /// </item> /// <item> /// Linq expression based on <paramref name="expression" /> (converted to a fully-qualified name) run against /// current model if result is non-<c>null</c> and can be converted to a <see cref="T:System.String" />. For example /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// property. /// </item> /// <item>Existing "value" entry in <paramref name="htmlAttributes" /> if any.</item> /// <item>Otherwise, <c>string.Empty</c>.</item> /// </list> /// </remarks> public static IHtmlContent MvcCoreBootstrapTextInput(this IHtmlHelper htmlHelper, string expression, object value, object htmlAttributes, Action <MvcCoreBootstrapTextInputBuilder> configAction = null) { TextInputConfig config = new TextInputConfig(); return(htmlHelper.Control(configAction, new MvcCoreBootstrapTextInputBuilder(config), new TextInputRenderer(config, new TooltipRenderer()), config, htmlHelper.TextBox(expression, value, htmlAttributes))); }
/// <summary> /// Renders a Bootstrap text input. /// </summary> /// <param name="htmlHelper">Html helper instance.</param> /// <param name="expression">Model property expression.</param> /// <param name="format"> /// The composite format <see cref="T:System.String" /> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// </param> /// <param name="configAction">Action that implements text input configuration.</param> /// <returns>Text input html markup.</returns> public static IHtmlContent MvcCoreBootstrapTextInputFor <TModel, TResult>(this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TResult> > expression, string format, Action <MvcCoreBootstrapTextInputBuilder> configAction = null) { TextInputConfig config = new TextInputConfig { Format = format }; return(htmlHelper.ControlFor(expression, configAction, new MvcCoreBootstrapTextInputBuilder(config), new TextInputRenderer(config, new TooltipRenderer()), config)); }
internal MvcCoreBootstrapTextInputBuilder(TextInputConfig config) { _config = config; }
public TextInputRenderer(TextInputConfig config, ITooltipRenderer tooltipRenderer) : base(config, tooltipRenderer) { _config = config; }