using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; namespace Microsoft.AspNet.Mvc.Rendering { /// /// An for Linq expressions. /// /// The of the model. public interface IHtmlHelper { /// /// Gets or sets the character that replaces periods in the ID attribute of an element. /// string IdAttributeDotReplacement { get; set; } /// /// Gets the view bag. /// dynamic ViewBag { get; } /// /// Gets the context information about the view. /// ViewContext ViewContext { get; } /// /// Gets the current view data. /// ViewDataDictionary ViewData { get; } /// /// Returns an anchor element (a element) that contains a URL path to the specified action. /// /// The inner text of the anchor element. /// The name of the action. /// The name of the controller. /// The protocol for the URL, such as "http" or "https". /// The host name for the URL. /// The URL fragment name (the anchor name). /// /// An object that contains the parameters for a route. The parameters are retrieved through reflection by /// examining the properties of the object. This object is typically created using object initializer syntax. /// Alternatively, an instance containing the route parameters. /// /// /// An object that contains the HTML attributes to set for the element. Alternatively, an /// instance containing the HTML attributes. /// /// /// An anchor element (a element). /// HtmlString ActionLink( [NotNull] string linkText, string actionName, string controllerName, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes); /// /// Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. /// /// /// The generated form field (anti-forgery token). /// HtmlString AntiForgeryToken(); /// /// Writes an opening
tag to the response. When the user submits the form, /// the request will be processed by an action method. ///
/// The name of the action method. /// The name of the controller. /// An object that contains the parameters for a route. The parameters are retrieved /// through reflection by examining the properties of the object. This object is typically created using object /// initializer syntax. Alternatively, an instance containing the /// route parameters. /// The HTTP method for processing the form, either GET or POST. /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// An instance which emits the closing {form} tag when disposed. MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes); /// /// Renders the closing tag to the response. /// void EndForm(); /// /// Render an input element of type "checkbox" with value "true" and an input element of type "hidden" with /// value "false". /// /// /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data /// only if value is not in submitted data and is null. /// /// /// If true, checkbox is initially checked. Ignore if named value is found in submitted data. Finally /// fall back to an existing "checked" value in . /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes); /// /// Render an input element of type "checkbox" with value "true" and an input element of type "hidden" with /// value "false". /// /// /// An expression that identifies the object that contains the properties to render. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString CheckBoxFor([NotNull] Expression> expression, object htmlAttributes); /// /// Returns HTML markup for each property in the object that is represented by the expression, using the specified /// template, HTML field ID, and additional view data. /// /// An expression that identifies the object that contains the properties to display. /// The name of the template that is used to render the object. /// /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have /// the same name. /// /// /// An anonymous object or dictionary that can contain additional view data that will be merged into the /// instance that is created for the template. /// /// The HTML markup for each property in the object that is represented by the expression. HtmlString Display(string expression, string templateName, string htmlFieldName, object additionalViewData); /// /// Returns HTML markup for each property in the object that is represented by the specified expression, using the /// template, an HTML field ID, and additional view data. /// /// The type of the value. /// An expression that identifies the object that contains the properties to display. /// The name of the template that is used to render the object. /// /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have /// the same name. /// /// /// An anonymous object or dictionary that can contain additional view data that will be merged into the /// instance that is created for the template. /// /// The HTML markup for each property in the object that is represented by the expression. HtmlString DisplayFor(Expression> expression, string templateName, string htmlFieldName, object additionalViewData); /// /// Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and additional /// view data. /// /// The name of the template that is used to render the object. /// /// A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the /// same name. /// /// /// An anonymous object or dictionary that can contain additional view data that will be merged into the /// instance that is created for the template. /// /// The HTML markup for each property in the model. HtmlString DisplayForModel(string templateName, string htmlFieldName, object additionalViewData); /// /// Gets the display name. /// /// An expression that identifies the object that contains the display name. /// /// The display name. /// HtmlString DisplayName(string expression); /// /// Gets the display name for the model. /// /// An expression that identifies the object that contains the display name. /// The type of the value. /// /// The display name for the model. /// HtmlString DisplayNameFor(Expression> expression); /// /// Gets the display name for the inner model if the current model represents a collection. /// /// The type of the inner model /// The type of the value. /// An expression that identifies the object that contains the display name. /// The display name for the inner model. HtmlString DisplayNameForInnerType(Expression> expression); /// /// Returns a single-selection HTML {select} element using the specified name of the form field, /// list items, option label, and HTML attributes. /// /// The name of the form field to return. /// A collection of objects that are used to populate the /// drop-down list. /// The text for a default empty item. This parameter can be null. /// An object that contains the HTML attributes to set for the {select} element. /// Alternatively, an instance containing the HTML attributes. /// /// An HTML {select} element with an {option} subelement for each item in the list. HtmlString DropDownList( string name, IEnumerable selectList, string optionLabel, object htmlAttributes); /// /// Returns a single-selection HTML {select} element for the object that is represented /// by the specified expression using the specified list items, option label, and HTML attributes. /// /// The type of the value. /// An expression that identifies the value to display. /// A collection of objects that are used to populate the /// drop-down list. /// The text for a default empty item. This parameter can be null. /// An object that contains the HTML attributes to set for the {select} element. /// Alternatively, an instance containing the HTML attributes. /// /// An HTML {select} element with an {option} subelement for each item in the list. HtmlString DropDownListFor( [NotNull] Expression> expression, IEnumerable selectList, string optionLabel, object htmlAttributes); /// /// Converts the value of the specified object to an HTML-encoded string. /// /// The object to encode. /// The HTML-encoded string. string Encode(object value); /// /// Converts the specified string to an HTML-encoded string. /// /// The string to encode. /// The HTML-encoded string. string Encode(string value); /// /// Formats the value. /// /// The value. /// The format string. /// The formatted value. string FormatValue(object value, string format); /// /// Creates an HTML element ID using the specified element name. /// /// The name of the HTML element. /// The ID of the HTML element. string GenerateIdFromName(string name); /// /// Render an input element of type "hidden". /// /// /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data /// only if value is not in submitted data and is null. /// /// /// If non-null, value to include in the element. Ignore if named value is found in submitted data. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString Hidden(string name, object value, object htmlAttributes); /// /// Render an input element of type "hidden". /// /// /// An expression that identifies the object that contains the properties to render. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString HiddenFor([NotNull] Expression> expression, object htmlAttributes); /// /// Returns an HTML label element and the property name of the property that is represented by the specified expression. /// /// An expression that identifies the property to display. /// The label text. /// An object that contains the HTML attributes to set for the element. /// /// An HTML label element and the property name of the property that is represented by the expression. /// HtmlString Label(string expression, string labelText, object htmlAttributes); /// /// Returns an HTML label element and the property name of the property that is represented by the specified expression. /// /// An expression that identifies the property to display. /// An object that contains the HTML attributes to set for the element. /// The type of the value. /// /// An HTML label element and the property name of the property that is represented by the expression. /// HtmlString LabelFor(Expression> expression, string labelText, object htmlAttributes); /// /// Gets the full HTML field name for the given expression . /// /// Name of an expression, relative to the current model. /// An that represents HTML markup. HtmlString Name(string name); /// /// Gets the full HTML field name for the given . /// /// The the returns. /// An expression, relative to the current model. /// An that represents HTML markup. HtmlString NameFor([NotNull] Expression> expression); /// /// Render an input element of type "password". /// /// /// Rendered element's name. Also use this name to find value in view data. Use view data /// only if value is not in submitted data and is null. /// /// /// If non-null, value to include in the element. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString Password(string name, object value, object htmlAttributes); /// /// Render an input element of type "password". /// /// /// An expression that identifies the object that contains the properties to render. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString PasswordFor([NotNull] Expression> expression, object htmlAttributes); /// /// Render an input element of type "radio". /// /// /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data /// only if value is not in submitted data and is null. /// /// /// If non-null, value to include in the element. May be null only if /// is also null. Also compared to value in submitted data or view data to /// determine if that parameter is null. Ignore if named value is found in /// submitted data. /// /// /// If true, radio button is initially selected. Ignore if named value is found in submitted data. Fall /// back to comparing with view data if this parameter is null. Finally /// fall back to an existing "checked" value in . /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes); /// /// Render an input element of type "radio". /// /// /// An expression that identifies the object that contains the properties to render. /// /// /// If non-null, value to compare with current expression value to determine whether radio button is /// checked. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. HtmlString RadioButtonFor([NotNull] Expression> expression, object value, object htmlAttributes); /// /// Wraps HTML markup in an , which will enable HTML markup to be /// rendered to the output without getting HTML encoded. /// /// HTML markup string. /// An that represents HTML markup. HtmlString Raw(string value); /// /// Wraps HTML markup from the string representation of an object in an , /// which will enable HTML markup to be rendered to the output without getting HTML encoded. /// /// object with string representation as HTML markup. /// An that represents HTML markup. HtmlString Raw(object value); /// /// Returns a partial view in string format. /// /// The name of the partial view to render and return. /// A model to pass into the partial view. /// A to pass into the partial view. /// A task that represents when rendering of the partial view into a string has completed. Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); /// /// Renders a partial view. /// /// The name of the partial view to render. /// A model to pass into the partial view. /// A to pass into the partial view. /// A task that represents when rendering has completed. Task RenderPartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); /// /// Render an input element of type "text". /// /// /// Rendered element's name. Also use this name to find value in submitted data or view data. Use view data /// only if value is not in submitted data and is null. /// /// /// If non-null, value to include in the element. Ignore if named value is found in submitted data. /// /// /// /// containing additional HTML attributes. /// /// New containing the rendered HTML. HtmlString TextBox(string name, object value, string format, IDictionary htmlAttributes); /// /// Render an input element of type "text". /// /// /// An expression that identifies the object that contains the properties to render. /// /// /// /// containing additional HTML attributes. /// /// New containing the rendered HTML. HtmlString TextBoxFor([NotNull] Expression> expression, string format, IDictionary htmlAttributes); /// /// Returns an unordered list (ul element) of validation messages that are in the /// object. /// /// true to have the summary display model-level errors only, or false to /// have the summary display all errors. /// The message to display with the validation summary. /// A dictionary that contains the HTML attributes for the element. /// An that contains an unordered list (ul element) of validation messages. /// HtmlString ValidationSummary(bool excludePropertyErrors, string message, IDictionary htmlAttributes); /// /// Returns the model value for the given expression . /// /// Name of an expression, relative to the current model. /// The optional format string to apply to the value. /// An that represents HTML markup. HtmlString Value([NotNull] string name, string format); /// /// Returns the model value for the given expression . /// /// An expression, relative to the current model. /// The optional format string to apply to the value. /// An that represents HTML markup. HtmlString ValueFor([NotNull] Expression> expression, string format); } }