// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Linq.Expressions; namespace Microsoft.AspNet.Mvc.Rendering { /// /// An for Linq expressions. /// /// The type of the model. public interface IHtmlHelper : IHtmlHelper { /// /// Gets the current view data. /// new ViewDataDictionary ViewData { get; } /// /// Returns an <input> element of type "checkbox" with value "true" and an <input> element of type /// "hidden" with value "false". /// /// An expression to be evaluated against the current model. /// /// An that contains the HTML attributes for the checkbox element. Alternatively, an /// instance containing the HTML attributes. /// /// A new containing the <input> elements. /// /// /// Combines and the string representation of the /// to set checkbox element's "name" attribute. Sanitizes the string /// representation of the to set checkbox element's "id" attribute. /// /// Determines checkbox element's "checked" attribute based on the following precedence: /// /// /// entry for the string representation of the /// if entry exists and can be converted to a . /// /// /// result if it is non-null and can be parsed as a /// . /// /// Existing "checked" entry in if any. /// Otherwise, does not include a "checked" attribute. /// /// /// In all but the case, includes a "checked" attribute with value "checked" /// if the values is true; does not include the attribute otherwise. /// /// HtmlString CheckBoxFor([NotNull] Expression> expression, object htmlAttributes); /// /// Returns HTML markup for the , using a display template, specified HTML field /// name, and additional view data. The template is found using the or the /// 's . /// /// An expression to be evaluated against the current model. /// The name of the template used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for properties /// that have the same name. /// /// /// An anonymous or that can contain additional /// view data that will be merged into the instance created for the /// template. /// /// The type of the result. /// A new containing the created HTML. /// /// For example the default display template includes markup for each property in the /// result. /// HtmlString DisplayFor( [NotNull] Expression> expression, string templateName, string htmlFieldName, object additionalViewData); /// /// Returns the display name for the specified . /// /// An expression to be evaluated against the current model. /// The type of the result. /// A containing the display name. string DisplayNameFor([NotNull] Expression> expression); /// /// Returns the display name for the specified /// if the current model represents a collection. /// /// An expression to be evaluated against an item in the current model. /// The type of items in the model collection. /// The type of the result. /// A containing the display name. string DisplayNameForInnerType( [NotNull] Expression> expression); /// /// Returns the simple display text for the specified . /// /// An expression to be evaluated against the current model. /// The type of the result. /// /// A containing the simple display text. /// If the result is null, returns /// . /// string DisplayTextFor([NotNull] Expression> expression); /// /// Returns a single-selection HTML <select> element for the , using the /// specified list items, option label, and HTML attributes. /// /// An expression to be evaluated against the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. /// /// /// The text for a default empty item. Does not include such an item if argument is null. /// /// /// An that contains the HTML attributes for the <select> element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// HtmlString DropDownListFor( [NotNull] Expression> expression, IEnumerable selectList, string optionLabel, object htmlAttributes); /// /// Returns HTML markup for the , using an editor template, specified HTML field /// name, and additional view data. The template is found using the or the /// 's . /// /// An expression to be evaluated against the current model. /// The name of the template that is used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for properties /// that have the same name. /// /// /// An anonymous or that can contain additional /// view data that will be merged into the instance created for the /// template. /// /// The type of the result. /// A new containing the <input> element(s). /// /// For example the default editor template includes <label> and <input> /// elements for each property in the result. /// HtmlString EditorFor( [NotNull] Expression> expression, string templateName, string htmlFieldName, object additionalViewData); /// /// Returns an <input> element of type "hidden" for the specified . /// /// An expression to be evaluated against the current model. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <input> element. /// /// /// Combines and the string representation of the /// to set <input> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// /// entry for the string representation of the /// if entry exists and can be converted to a . /// /// /// result if it is non-null and can be parsed as a /// . /// /// Existing "value" entry in if any. /// Otherwise, string.Empty. /// /// HtmlString HiddenFor( [NotNull] Expression> expression, object htmlAttributes); /// /// Returns the HTML element Id for the specified . /// /// An expression to be evaluated against the current model. /// The type of the result. /// A containing the element Id. string IdFor([NotNull] Expression> expression); /// /// Returns a <label> element for the specified . /// /// An expression to be evaluated against the current model. /// The inner text of the element. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <label> element. HtmlString LabelFor( [NotNull] Expression> expression, string labelText, object htmlAttributes); /// /// Returns a multi-selection <select> element for the , using the /// specified list items and HTML attributes. /// /// An expression to be evaluated against the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. /// /// /// An that contains the HTML attributes for the <select> element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// HtmlString ListBoxFor( [NotNull] Expression> expression, IEnumerable selectList, object htmlAttributes); /// /// Returns the full HTML element name for the specified . /// /// An expression to be evaluated against the current model. /// The type of the result. /// A containing the element name. string NameFor([NotNull] Expression> expression); /// /// Returns an <input> element of type "password" for the specified . /// /// An expression to be evaluated against the current model. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <input> element. /// /// /// Combines and the string representation of the /// to set <input> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// /// result if it is non-null and can be parsed as a /// . /// /// Existing "value" entry in if any. /// Otherwise, string.Empty. /// /// HtmlString PasswordFor( [NotNull] Expression> expression, object htmlAttributes); /// /// Returns an <input> element of type "radio" for the specified . /// /// An expression to be evaluated against the current model. /// Value to include in the element. Must not be null. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <input> element. /// /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. Converts the /// to a to set element's "value" attribute. /// /// Determines <input> element's "checked" attribute based on the following precedence: /// /// /// entry for the string representation of the /// if entry exists and can be converted to a . /// /// /// result if it is non-null and can be parsed as a . /// /// Existing "checked" entry in if any. /// Otherwise, does not include a "checked" attribute. /// /// /// In all but the and default cases, includes a "checked" attribute with /// value "checked" if the values is equal to a converted for /// ; does not include the attribute otherwise. /// /// HtmlString RadioButtonFor( [NotNull] Expression> expression, [NotNull] object value, object htmlAttributes); /// /// Returns a <textarea> element for the specified . /// /// An expression to be evaluated against the current model. /// Number of rows in the textarea. /// Number of columns in the textarea. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <textarea> element. /// /// /// Combines and the string representation of the /// to set <textarea> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// /// entry for the string representation of the /// if entry exists and can be converted to a . /// /// /// result if it is non-null and can be parsed as a . /// /// Otherwise, string.Empty. /// /// HtmlString TextAreaFor( [NotNull] Expression> expression, int rows, int columns, object htmlAttributes); /// /// Returns an <input> element of type "text" for the specified . /// /// An expression to be evaluated against the current model. /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// /// The type of the result. /// A new containing the <input> element. /// /// /// Combines and the string representation of the /// to set <input> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// /// entry for the string representation of the /// if entry exists and can be converted to a . /// /// /// result if it is non-null and can be parsed as a . /// Formats result using or converts result to a directly if /// is null or empty. /// /// Existing "value" entry in if any. /// Otherwise, string.Empty. /// /// HtmlString TextBoxFor( [NotNull] Expression> expression, string format, object htmlAttributes); /// /// Returns the validation message if an error exists in the /// object for the specified . /// /// An expression to be evaluated against the current model. /// /// The message to be displayed. If null or empty, method extracts an error string from the /// object. Message will always be visible but client-side /// validation may update the associated CSS class. /// /// /// An that contains the HTML attributes for the element. /// Alternatively, an instance containing the HTML attributes. /// /// /// The tag to wrap the in the generated HTML. Its default value is /// . /// /// The type of the result. /// /// A new containing the element. null if the /// is valid and client-side validation is disabled. /// HtmlString ValidationMessageFor( [NotNull] Expression> expression, string message, object htmlAttributes, string tag); /// /// Returns the formatted value for the specified . /// /// An expression to be evaluated against the current model. /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// /// The type of the result. /// A containing the formatted value. /// /// Converts the result to a directly if /// is null or empty. /// string ValueFor( [NotNull] Expression> expression, string format); } }