Make HTML helper parameter names consistent

- #944
- name `string` expression name and `Expression<Func<TModel, TResult>>`
  parameters "expression"
 - single special case is `GenerateIdFromName(string fullName)` since every
   other expression name is relative to the current
   `ViewData,TemplateInfo.HtmlFieldPrefix` value
 - applied from `IHtmlHelper` and `IHtmlGenerator` on up
- name `IHtmlHelper` and `IHtmlHelper<TModel>` parameters "htmlHelper"
- rename `TProperty` and `TValue` type parameters to `TResult`

nits:
- clean up abbreviated names in `CachedExpressionCompiler`
- change `ObjectToDictionary()`'s parameter name to `value`
- use `nameof` more to make renaming (and refactoring) easier in the future
- rewrap parameters and arguments to avoid long lines and orphans
This commit is contained in:
Doug Bunting 2015-02-15 22:50:42 -08:00
parent f19c2e493d
commit 8eb63271b5
27 changed files with 1261 additions and 1003 deletions

View File

@ -13,6 +13,6 @@
} }
@Html.TextBox( @Html.TextBox(
name: null, expression: null,
value: FormattedValue, value: FormattedValue,
htmlAttributes: new { @class = "text-box single-line", style = "font-weight: bold", }) htmlAttributes: new { @class = "text-box single-line", style = "font-weight: bold", })

View File

@ -15,54 +15,56 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
// relying on cache lookups and other techniques to save time if appropriate. // relying on cache lookups and other techniques to save time if appropriate.
// If the provided expression is particularly obscure and the system doesn't know // If the provided expression is particularly obscure and the system doesn't know
// how to handle it, we'll just compile the expression as normal. // how to handle it, we'll just compile the expression as normal.
public static Func<TModel, TValue> Process<TModel, TValue>( public static Func<TModel, TResult> Process<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> lambdaExpression) [NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return Compiler<TModel, TValue>.Compile(lambdaExpression); return Compiler<TModel, TResult>.Compile(expression);
} }
private static class Compiler<TIn, TOut> private static class Compiler<TModel, TResult>
{ {
private static Func<TIn, TOut> _identityFunc; private static Func<TModel, TResult> _identityFunc;
private static readonly ConcurrentDictionary<MemberInfo, Func<TIn, TOut>> _simpleMemberAccessDict = private static readonly ConcurrentDictionary<MemberInfo, Func<TModel, TResult>> _simpleMemberAccessDict =
new ConcurrentDictionary<MemberInfo, Func<TIn, TOut>>(); new ConcurrentDictionary<MemberInfo, Func<TModel, TResult>>();
private static readonly ConcurrentDictionary<MemberInfo, Func<object, TOut>> _constMemberAccessDict = private static readonly ConcurrentDictionary<MemberInfo, Func<object, TResult>> _constMemberAccessDict =
new ConcurrentDictionary<MemberInfo, Func<object, TOut>>(); new ConcurrentDictionary<MemberInfo, Func<object, TResult>>();
public static Func<TIn, TOut> Compile([NotNull] Expression<Func<TIn, TOut>> expr) public static Func<TModel, TResult> Compile([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return CompileFromIdentityFunc(expr) return CompileFromIdentityFunc(expression)
?? CompileFromConstLookup(expr) ?? CompileFromConstLookup(expression)
?? CompileFromMemberAccess(expr) ?? CompileFromMemberAccess(expression)
?? CompileSlow(expr); ?? CompileSlow(expression);
} }
private static Func<TIn, TOut> CompileFromConstLookup([NotNull] Expression<Func<TIn, TOut>> expr) private static Func<TModel, TResult> CompileFromConstLookup(
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
var constExpr = expr.Body as ConstantExpression; var constantExpression = expression.Body as ConstantExpression;
if (constExpr != null) if (constantExpression != null)
{ {
// model => {const} // model => {const}
var constantValue = (TOut)constExpr.Value; var constantValue = (TResult)constantExpression.Value;
return _ => constantValue; return _ => constantValue;
} }
return null; return null;
} }
private static Func<TIn, TOut> CompileFromIdentityFunc([NotNull] Expression<Func<TIn, TOut>> expr) private static Func<TModel, TResult> CompileFromIdentityFunc(
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
if (expr.Body == expr.Parameters[0]) if (expression.Body == expression.Parameters[0])
{ {
// model => model // model => model
// Don't need to lock, as all identity funcs are identical. // Don't need to lock, as all identity funcs are identical.
if (_identityFunc == null) if (_identityFunc == null)
{ {
_identityFunc = expr.Compile(); _identityFunc = expression.Compile();
} }
return _identityFunc; return _identityFunc;
@ -71,7 +73,8 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
return null; return null;
} }
private static Func<TIn, TOut> CompileFromMemberAccess([NotNull] Expression<Func<TIn, TOut>> expr) private static Func<TModel, TResult> CompileFromMemberAccess(
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
// Performance tests show that on the x64 platform, special-casing static member and // Performance tests show that on the x64 platform, special-casing static member and
// captured local variable accesses is faster than letting the fingerprinting system // captured local variable accesses is faster than letting the fingerprinting system
@ -79,42 +82,43 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
// by around one microsecond, so it's not worth it to complicate the logic here with // by around one microsecond, so it's not worth it to complicate the logic here with
// an architecture check. // an architecture check.
var memberExpr = expr.Body as MemberExpression; var memberExpression = expression.Body as MemberExpression;
if (memberExpr != null) if (memberExpression != null)
{ {
if (memberExpr.Expression == expr.Parameters[0] || memberExpr.Expression == null) if (memberExpression.Expression == expression.Parameters[0] || memberExpression.Expression == null)
{ {
// model => model.Member or model => StaticMember // model => model.Member or model => StaticMember
return _simpleMemberAccessDict.GetOrAdd(memberExpr.Member, _ => expr.Compile()); return _simpleMemberAccessDict.GetOrAdd(memberExpression.Member, _ => expression.Compile());
} }
var constExpr = memberExpr.Expression as ConstantExpression; var constantExpression = memberExpression.Expression as ConstantExpression;
if (constExpr != null) if (constantExpression != null)
{ {
// model => {const}.Member (captured local variable) // model => {const}.Member (captured local variable)
var del = _constMemberAccessDict.GetOrAdd(memberExpr.Member, _ => var compiledExpression = _constMemberAccessDict.GetOrAdd(memberExpression.Member, _ =>
{ {
// rewrite as capturedLocal => ((TDeclaringType)capturedLocal).Member // rewrite as capturedLocal => ((TDeclaringType)capturedLocal).Member
var constParamExpr = Expression.Parameter(typeof(object), "capturedLocal"); var parameterExpression = Expression.Parameter(typeof(object), "capturedLocal");
var constCastExpr = Expression.Convert(constParamExpr, memberExpr.Member.DeclaringType); var castExpression =
var newMemberAccessExpr = memberExpr.Update(constCastExpr); Expression.Convert(parameterExpression, memberExpression.Member.DeclaringType);
var newLambdaExpr = var newMemberExpression = memberExpression.Update(castExpression);
Expression.Lambda<Func<object, TOut>>(newMemberAccessExpr, constParamExpr); var newExpression =
return newLambdaExpr.Compile(); Expression.Lambda<Func<object, TResult>>(newMemberExpression, parameterExpression);
return newExpression.Compile();
}); });
var capturedLocal = constExpr.Value; var capturedLocal = constantExpression.Value;
return _ => del(capturedLocal); return _ => compiledExpression(capturedLocal);
} }
} }
return null; return null;
} }
private static Func<TIn, TOut> CompileSlow([NotNull] Expression<Func<TIn, TOut>> expr) private static Func<TModel, TResult> CompileSlow([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
// fallback compilation system - just compile the expression directly // fallback compilation system - just compile the expression directly
return expr.Compile(); return expression.Compile();
} }
} }
} }

View File

@ -16,10 +16,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
public static string GetExpressionText(string expression) public static string GetExpressionText(string expression)
{ {
// If it's exactly "model", then give them an empty string, to replicate the lambda behavior. // If it's exactly "model", then give them an empty string, to replicate the lambda behavior.
return return string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase) ? string.Empty : expression;
string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase)
? string.Empty
: expression;
} }
public static string GetExpressionText([NotNull] LambdaExpression expression) public static string GetExpressionText([NotNull] LambdaExpression expression)
@ -91,7 +88,8 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
return string.Empty; return string.Empty;
} }
private static string GetIndexerInvocation([NotNull] Expression expression, private static string GetIndexerInvocation(
[NotNull] Expression expression,
[NotNull] ParameterExpression[] parameters) [NotNull] ParameterExpression[] parameters)
{ {
var converted = Expression.Convert(expression, typeof(object)); var converted = Expression.Convert(expression, typeof(object));

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Core;
@ -12,9 +11,9 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
{ {
public static class ExpressionMetadataProvider public static class ExpressionMetadataProvider
{ {
public static ModelMetadata FromLambdaExpression<TParameter, TValue>( public static ModelMetadata FromLambdaExpression<TModel, TResult>(
[NotNull] Expression<Func<TParameter, TValue>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
[NotNull] ViewDataDictionary<TParameter> viewData, [NotNull] ViewDataDictionary<TModel> viewData,
IModelMetadataProvider metadataProvider) IModelMetadataProvider metadataProvider)
{ {
string propertyName = null; string propertyName = null;
@ -70,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions
return GetMetadataFromProvider( return GetMetadataFromProvider(
modelAccessor, modelAccessor,
typeof(TValue), typeof(TResult),
propertyName, propertyName,
container, container,
containerType, containerType,

View File

@ -15,16 +15,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
public static class DefaultDisplayTemplates public static class DefaultDisplayTemplates
{ {
public static string BooleanTemplate(IHtmlHelper html) public static string BooleanTemplate(IHtmlHelper htmlHelper)
{ {
bool? value = null; bool? value = null;
if (html.ViewData.Model != null) if (htmlHelper.ViewData.Model != null)
{ {
value = Convert.ToBoolean(html.ViewData.Model, CultureInfo.InvariantCulture); value = Convert.ToBoolean(htmlHelper.ViewData.Model, CultureInfo.InvariantCulture);
} }
return html.ViewData.ModelMetadata.IsNullableValueType ? return htmlHelper.ViewData.ModelMetadata.IsNullableValueType ?
BooleanTemplateDropDownList(html, value) : BooleanTemplateDropDownList(htmlHelper, value) :
BooleanTemplateCheckbox(value ?? false); BooleanTemplateCheckbox(value ?? false);
} }
@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
return inputTag.ToString(TagRenderMode.SelfClosing); return inputTag.ToString(TagRenderMode.SelfClosing);
} }
private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) private static string BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value)
{ {
var selectTag = new TagBuilder("select"); var selectTag = new TagBuilder("select");
selectTag.AddCssClass("list-box"); selectTag.AddCssClass("list-box");
@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
foreach (var item in TriStateValues(value)) foreach (var item in TriStateValues(value))
{ {
var encodedText = html.Encode(item.Text); var encodedText = htmlHelper.Encode(item.Text);
var option = DefaultHtmlGenerator.GenerateOption(item, encodedText); var option = DefaultHtmlGenerator.GenerateOption(item, encodedText);
builder.Append(option); builder.Append(option);
} }
@ -89,9 +89,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
}; };
} }
public static string CollectionTemplate(IHtmlHelper html) public static string CollectionTemplate(IHtmlHelper htmlHelper)
{ {
var model = html.ViewData.ModelMetadata.Model; var model = htmlHelper.ViewData.ModelMetadata.Model;
if (model == null) if (model == null)
{ {
return string.Empty; return string.Empty;
@ -114,16 +114,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
var typeInCollectionIsNullableValueType = typeInCollection.IsNullableValueType(); var typeInCollectionIsNullableValueType = typeInCollection.IsNullableValueType();
var oldPrefix = html.ViewData.TemplateInfo.HtmlFieldPrefix; var oldPrefix = htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix;
try try
{ {
html.ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty; htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty;
var fieldNameBase = oldPrefix; var fieldNameBase = oldPrefix;
var result = new StringBuilder(); var result = new StringBuilder();
var serviceProvider = html.ViewContext.HttpContext.RequestServices; var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
var metadataProvider = serviceProvider.GetRequiredService<IModelMetadataProvider>(); var metadataProvider = serviceProvider.GetRequiredService<IModelMetadataProvider>();
var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>(); var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>();
@ -141,8 +141,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
var templateBuilder = new TemplateBuilder( var templateBuilder = new TemplateBuilder(
viewEngine, viewEngine,
html.ViewContext, htmlHelper.ViewContext,
html.ViewData, htmlHelper.ViewData,
metadata, metadata,
htmlFieldName: fieldName, htmlFieldName: fieldName,
templateName: null, templateName: null,
@ -157,51 +157,51 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
finally finally
{ {
html.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix; htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix;
} }
} }
public static string DecimalTemplate(IHtmlHelper html) public static string DecimalTemplate(IHtmlHelper htmlHelper)
{ {
if (html.ViewData.TemplateInfo.FormattedModelValue == html.ViewData.ModelMetadata.Model) if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == htmlHelper.ViewData.ModelMetadata.Model)
{ {
html.ViewData.TemplateInfo.FormattedModelValue = htmlHelper.ViewData.TemplateInfo.FormattedModelValue =
string.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewData.ModelMetadata.Model); string.Format(CultureInfo.CurrentCulture, "{0:0.00}", htmlHelper.ViewData.ModelMetadata.Model);
} }
return StringTemplate(html); return StringTemplate(htmlHelper);
} }
public static string EmailAddressTemplate(IHtmlHelper html) public static string EmailAddressTemplate(IHtmlHelper htmlHelper)
{ {
var uriString = "mailto:" + ((html.ViewData.Model == null) ? var uriString = "mailto:" + ((htmlHelper.ViewData.Model == null) ?
string.Empty : string.Empty :
html.ViewData.Model.ToString()); htmlHelper.ViewData.Model.ToString());
var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? var linkedText = (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == null) ?
string.Empty : string.Empty :
html.ViewData.TemplateInfo.FormattedModelValue.ToString(); htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString();
return HyperlinkTemplate(uriString, linkedText); return HyperlinkTemplate(uriString, linkedText);
} }
public static string HiddenInputTemplate(IHtmlHelper html) public static string HiddenInputTemplate(IHtmlHelper htmlHelper)
{ {
if (html.ViewData.ModelMetadata.HideSurroundingHtml) if (htmlHelper.ViewData.ModelMetadata.HideSurroundingHtml)
{ {
return string.Empty; return string.Empty;
} }
return StringTemplate(html); return StringTemplate(htmlHelper);
} }
public static string HtmlTemplate(IHtmlHelper html) public static string HtmlTemplate(IHtmlHelper htmlHelper)
{ {
return html.ViewData.TemplateInfo.FormattedModelValue.ToString(); return htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString();
} }
public static string ObjectTemplate(IHtmlHelper html) public static string ObjectTemplate(IHtmlHelper htmlHelper)
{ {
var viewData = html.ViewData; var viewData = htmlHelper.ViewData;
var templateInfo = viewData.TemplateInfo; var templateInfo = viewData.TemplateInfo;
var modelMetadata = viewData.ModelMetadata; var modelMetadata = viewData.ModelMetadata;
var builder = new StringBuilder(); var builder = new StringBuilder();
@ -216,13 +216,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
var text = modelMetadata.SimpleDisplayText; var text = modelMetadata.SimpleDisplayText;
if (modelMetadata.HtmlEncode) if (modelMetadata.HtmlEncode)
{ {
text = html.Encode(text); text = htmlHelper.Encode(text);
} }
return text; return text;
} }
var serviceProvider = html.ViewContext.HttpContext.RequestServices; var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>(); var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>();
foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo)))
@ -248,8 +248,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
var templateBuilder = new TemplateBuilder( var templateBuilder = new TemplateBuilder(
viewEngine, viewEngine,
html.ViewContext, htmlHelper.ViewContext,
html.ViewData, htmlHelper.ViewData,
propertyMetadata, propertyMetadata,
htmlFieldName: propertyMetadata.PropertyName, htmlFieldName: propertyMetadata.PropertyName,
templateName: null, templateName: null,
@ -275,17 +275,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
!templateInfo.Visited(metadata); !templateInfo.Visited(metadata);
} }
public static string StringTemplate(IHtmlHelper html) public static string StringTemplate(IHtmlHelper htmlHelper)
{ {
return html.Encode(html.ViewData.TemplateInfo.FormattedModelValue); return htmlHelper.Encode(htmlHelper.ViewData.TemplateInfo.FormattedModelValue);
} }
public static string UrlTemplate(IHtmlHelper html) public static string UrlTemplate(IHtmlHelper htmlHelper)
{ {
var uriString = (html.ViewData.Model == null) ? string.Empty : html.ViewData.Model.ToString(); var uriString = (htmlHelper.ViewData.Model == null) ? string.Empty : htmlHelper.ViewData.Model.ToString();
var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? var linkedText = (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == null) ?
string.Empty : string.Empty :
html.ViewData.TemplateInfo.FormattedModelValue.ToString(); htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString();
return HyperlinkTemplate(uriString, linkedText); return HyperlinkTemplate(uriString, linkedText);
} }

View File

@ -17,41 +17,41 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
private const string HtmlAttributeKey = "htmlAttributes"; private const string HtmlAttributeKey = "htmlAttributes";
public static string BooleanTemplate(IHtmlHelper html) public static string BooleanTemplate(IHtmlHelper htmlHelper)
{ {
bool? value = null; bool? value = null;
if (html.ViewData.Model != null) if (htmlHelper.ViewData.Model != null)
{ {
value = Convert.ToBoolean(html.ViewData.Model, CultureInfo.InvariantCulture); value = Convert.ToBoolean(htmlHelper.ViewData.Model, CultureInfo.InvariantCulture);
} }
return html.ViewData.ModelMetadata.IsNullableValueType ? return htmlHelper.ViewData.ModelMetadata.IsNullableValueType ?
BooleanTemplateDropDownList(html, value) : BooleanTemplateDropDownList(htmlHelper, value) :
BooleanTemplateCheckbox(html, value ?? false); BooleanTemplateCheckbox(htmlHelper, value ?? false);
} }
private static string BooleanTemplateCheckbox(IHtmlHelper html, bool value) private static string BooleanTemplateCheckbox(IHtmlHelper htmlHelper, bool value)
{ {
return html.CheckBox( return htmlHelper.CheckBox(
name: null, expression: null,
isChecked: value, isChecked: value,
htmlAttributes: CreateHtmlAttributes(html, "check-box")) htmlAttributes: CreateHtmlAttributes(htmlHelper, "check-box"))
.ToString(); .ToString();
} }
private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) private static string BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value)
{ {
return html.DropDownList( return htmlHelper.DropDownList(
name: null, expression: null,
selectList: DefaultDisplayTemplates.TriStateValues(value), selectList: DefaultDisplayTemplates.TriStateValues(value),
optionLabel: null, optionLabel: null,
htmlAttributes: CreateHtmlAttributes(html, "list-box tri-state")) htmlAttributes: CreateHtmlAttributes(htmlHelper, "list-box tri-state"))
.ToString(); .ToString();
} }
public static string CollectionTemplate(IHtmlHelper html) public static string CollectionTemplate(IHtmlHelper htmlHelper)
{ {
var viewData = html.ViewData; var viewData = htmlHelper.ViewData;
var model = viewData.ModelMetadata.Model; var model = viewData.ModelMetadata.Model;
if (model == null) if (model == null)
{ {
@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var fieldNameBase = oldPrefix; var fieldNameBase = oldPrefix;
var result = new StringBuilder(); var result = new StringBuilder();
var serviceProvider = html.ViewContext.HttpContext.RequestServices; var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
var metadataProvider = serviceProvider.GetRequiredService<IModelMetadataProvider>(); var metadataProvider = serviceProvider.GetRequiredService<IModelMetadataProvider>();
var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>(); var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>();
@ -101,8 +101,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
var templateBuilder = new TemplateBuilder( var templateBuilder = new TemplateBuilder(
viewEngine, viewEngine,
html.ViewContext, htmlHelper.ViewContext,
html.ViewData, htmlHelper.ViewData,
metadata, metadata,
htmlFieldName: fieldName, htmlFieldName: fieldName,
templateName: null, templateName: null,
@ -121,20 +121,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
} }
public static string DecimalTemplate(IHtmlHelper html) public static string DecimalTemplate(IHtmlHelper htmlHelper)
{ {
if (html.ViewData.TemplateInfo.FormattedModelValue == html.ViewData.ModelMetadata.Model) if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == htmlHelper.ViewData.ModelMetadata.Model)
{ {
html.ViewData.TemplateInfo.FormattedModelValue = htmlHelper.ViewData.TemplateInfo.FormattedModelValue =
string.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewData.ModelMetadata.Model); string.Format(CultureInfo.CurrentCulture, "{0:0.00}", htmlHelper.ViewData.ModelMetadata.Model);
} }
return StringTemplate(html); return StringTemplate(htmlHelper);
} }
public static string HiddenInputTemplate(IHtmlHelper html) public static string HiddenInputTemplate(IHtmlHelper htmlHelper)
{ {
var viewData = html.ViewData; var viewData = htmlHelper.ViewData;
var model = viewData.Model; var model = viewData.Model;
string result; string result;
@ -144,7 +144,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
else else
{ {
result = DefaultDisplayTemplates.StringTemplate(html); result = DefaultDisplayTemplates.StringTemplate(htmlHelper);
} }
// Special-case opaque values and arbitrary binary data. // Special-case opaque values and arbitrary binary data.
@ -155,18 +155,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
var htmlAttributesObject = viewData[HtmlAttributeKey]; var htmlAttributesObject = viewData[HtmlAttributeKey];
var hiddenResult = html.Hidden(name: null, value: model, htmlAttributes: htmlAttributesObject); var hiddenResult = htmlHelper.Hidden(expression: null, value: model, htmlAttributes: htmlAttributesObject);
result += hiddenResult.ToString(); result += hiddenResult.ToString();
return result; return result;
} }
private static IDictionary<string, object> CreateHtmlAttributes( private static IDictionary<string, object> CreateHtmlAttributes(
IHtmlHelper html, IHtmlHelper htmlHelper,
string className, string className,
string inputType = null) string inputType = null)
{ {
var htmlAttributesObject = html.ViewData[HtmlAttributeKey]; var htmlAttributesObject = htmlHelper.ViewData[HtmlAttributeKey];
if (htmlAttributesObject != null) if (htmlAttributesObject != null)
{ {
return MergeHtmlAttributes(htmlAttributesObject, className, inputType); return MergeHtmlAttributes(htmlAttributesObject, className, inputType);
@ -212,20 +212,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
return htmlAttributes; return htmlAttributes;
} }
public static string MultilineTemplate(IHtmlHelper html) public static string MultilineTemplate(IHtmlHelper htmlHelper)
{ {
var htmlString = html.TextArea( var htmlString = htmlHelper.TextArea(
name: string.Empty, expression: string.Empty,
value: html.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(), value: htmlHelper.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(),
rows: 0, rows: 0,
columns: 0, columns: 0,
htmlAttributes: CreateHtmlAttributes(html, "text-box multi-line")); htmlAttributes: CreateHtmlAttributes(htmlHelper, "text-box multi-line"));
return htmlString.ToString(); return htmlString.ToString();
} }
public static string ObjectTemplate(IHtmlHelper html) public static string ObjectTemplate(IHtmlHelper htmlHelper)
{ {
var viewData = html.ViewData; var viewData = htmlHelper.ViewData;
var templateInfo = viewData.TemplateInfo; var templateInfo = viewData.TemplateInfo;
var modelMetadata = viewData.ModelMetadata; var modelMetadata = viewData.ModelMetadata;
var builder = new StringBuilder(); var builder = new StringBuilder();
@ -240,13 +240,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
var text = modelMetadata.SimpleDisplayText; var text = modelMetadata.SimpleDisplayText;
if (modelMetadata.HtmlEncode) if (modelMetadata.HtmlEncode)
{ {
text = html.Encode(text); text = htmlHelper.Encode(text);
} }
return text; return text;
} }
var serviceProvider = html.ViewContext.HttpContext.RequestServices; var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>(); var viewEngine = serviceProvider.GetRequiredService<ICompositeViewEngine>();
foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo)))
@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
if (!propertyMetadata.HideSurroundingHtml) if (!propertyMetadata.HideSurroundingHtml)
{ {
var label = html.Label( var label = htmlHelper.Label(
propertyMetadata.PropertyName, propertyMetadata.PropertyName,
labelText: null, labelText: null,
htmlAttributes: null) htmlAttributes: null)
@ -276,8 +276,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
var templateBuilder = new TemplateBuilder( var templateBuilder = new TemplateBuilder(
viewEngine, viewEngine,
html.ViewContext, htmlHelper.ViewContext,
html.ViewData, htmlHelper.ViewData,
propertyMetadata, propertyMetadata,
htmlFieldName: propertyMetadata.PropertyName, htmlFieldName: propertyMetadata.PropertyName,
templateName: null, templateName: null,
@ -289,7 +289,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
if (!propertyMetadata.HideSurroundingHtml) if (!propertyMetadata.HideSurroundingHtml)
{ {
builder.Append(" "); builder.Append(" ");
builder.Append(html.ValidationMessage( builder.Append(htmlHelper.ValidationMessage(
propertyMetadata.PropertyName, propertyMetadata.PropertyName,
message: null, message: null,
htmlAttributes: null, htmlAttributes: null,
@ -302,12 +302,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
return builder.ToString(); return builder.ToString();
} }
public static string PasswordTemplate(IHtmlHelper html) public static string PasswordTemplate(IHtmlHelper htmlHelper)
{ {
return html.Password( return htmlHelper.Password(
name: null, expression: null,
value: html.ViewData.TemplateInfo.FormattedModelValue, value: htmlHelper.ViewData.TemplateInfo.FormattedModelValue,
htmlAttributes: CreateHtmlAttributes(html, "text-box single-line password")) htmlAttributes: CreateHtmlAttributes(htmlHelper, "text-box single-line password"))
.ToString(); .ToString();
} }
@ -319,88 +319,91 @@ namespace Microsoft.AspNet.Mvc.Rendering
&& !templateInfo.Visited(metadata); && !templateInfo.Visited(metadata);
} }
public static string StringTemplate(IHtmlHelper html) public static string StringTemplate(IHtmlHelper htmlHelper)
{ {
return GenerateTextBox(html); return GenerateTextBox(htmlHelper);
} }
public static string PhoneNumberInputTemplate(IHtmlHelper html) public static string PhoneNumberInputTemplate(IHtmlHelper htmlHelper)
{ {
return GenerateTextBox(html, inputType: "tel"); return GenerateTextBox(htmlHelper, inputType: "tel");
} }
public static string UrlInputTemplate(IHtmlHelper html) public static string UrlInputTemplate(IHtmlHelper htmlHelper)
{ {
return GenerateTextBox(html, inputType: "url"); return GenerateTextBox(htmlHelper, inputType: "url");
} }
public static string EmailAddressInputTemplate(IHtmlHelper html) public static string EmailAddressInputTemplate(IHtmlHelper htmlHelper)
{ {
return GenerateTextBox(html, inputType: "email"); return GenerateTextBox(htmlHelper, inputType: "email");
} }
public static string DateTimeInputTemplate(IHtmlHelper html) public static string DateTimeInputTemplate(IHtmlHelper htmlHelper)
{ {
ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-ddTHH:mm:ss.fffK}"); ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-ddTHH:mm:ss.fffK}");
return GenerateTextBox(html, inputType: "datetime"); return GenerateTextBox(htmlHelper, inputType: "datetime");
} }
public static string DateTimeLocalInputTemplate(IHtmlHelper html) public static string DateTimeLocalInputTemplate(IHtmlHelper htmlHelper)
{ {
ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-ddTHH:mm:ss.fff}"); ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-ddTHH:mm:ss.fff}");
return GenerateTextBox(html, inputType: "datetime-local"); return GenerateTextBox(htmlHelper, inputType: "datetime-local");
} }
public static string DateInputTemplate(IHtmlHelper html) public static string DateInputTemplate(IHtmlHelper htmlHelper)
{ {
ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-dd}"); ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-dd}");
return GenerateTextBox(html, inputType: "date"); return GenerateTextBox(htmlHelper, inputType: "date");
} }
public static string TimeInputTemplate(IHtmlHelper html) public static string TimeInputTemplate(IHtmlHelper htmlHelper)
{ {
ApplyRfc3339DateFormattingIfNeeded(html, "{0:HH:mm:ss.fff}"); ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:HH:mm:ss.fff}");
return GenerateTextBox(html, inputType: "time"); return GenerateTextBox(htmlHelper, inputType: "time");
} }
public static string NumberInputTemplate(IHtmlHelper html) public static string NumberInputTemplate(IHtmlHelper htmlHelper)
{ {
return GenerateTextBox(html, inputType: "number"); return GenerateTextBox(htmlHelper, inputType: "number");
} }
private static void ApplyRfc3339DateFormattingIfNeeded(IHtmlHelper html, string format) private static void ApplyRfc3339DateFormattingIfNeeded(IHtmlHelper htmlHelper, string format)
{ {
if (html.Html5DateRenderingMode != Html5DateRenderingMode.Rfc3339) if (htmlHelper.Html5DateRenderingMode != Html5DateRenderingMode.Rfc3339)
{ {
return; return;
} }
var metadata = html.ViewData.ModelMetadata; var metadata = htmlHelper.ViewData.ModelMetadata;
var value = metadata.Model; var value = metadata.Model;
if (html.ViewData.TemplateInfo.FormattedModelValue != value && metadata.HasNonDefaultEditFormat) if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue != value && metadata.HasNonDefaultEditFormat)
{ {
return; return;
} }
if (value is DateTime || value is DateTimeOffset) if (value is DateTime || value is DateTimeOffset)
{ {
html.ViewData.TemplateInfo.FormattedModelValue = htmlHelper.ViewData.TemplateInfo.FormattedModelValue =
string.Format(CultureInfo.InvariantCulture, format, value); string.Format(CultureInfo.InvariantCulture, format, value);
} }
} }
private static string GenerateTextBox(IHtmlHelper html, string inputType = null) private static string GenerateTextBox(IHtmlHelper htmlHelper, string inputType = null)
{ {
return GenerateTextBox(html, inputType, html.ViewData.TemplateInfo.FormattedModelValue); return GenerateTextBox(htmlHelper, inputType, htmlHelper.ViewData.TemplateInfo.FormattedModelValue);
} }
private static string GenerateTextBox(IHtmlHelper html, string inputType, object value) private static string GenerateTextBox(IHtmlHelper htmlHelper, string inputType, object value)
{ {
return html.TextBox( var htmlAttributes =
name: null, CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: inputType);
return htmlHelper.TextBox(
current: null,
value: value, value: value,
format: null, format: null,
htmlAttributes: CreateHtmlAttributes(html, className: "text-box single-line", inputType: inputType)) htmlAttributes: htmlAttributes)
.ToString(); .ToString();
} }
} }

View File

@ -90,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateCheckBox( public virtual TagBuilder GenerateCheckBox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
bool? isChecked, bool? isChecked,
object htmlAttributes) object htmlAttributes)
{ {
@ -121,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
InputType.CheckBox, InputType.CheckBox,
metadata, metadata,
name, expression,
value: "true", value: "true",
useViewData: (metadata == null && !isChecked.HasValue), useViewData: (metadata == null && !isChecked.HasValue),
isChecked: isChecked ?? false, isChecked: isChecked ?? false,
@ -135,13 +135,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateHiddenForCheckbox( public virtual TagBuilder GenerateHiddenForCheckbox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name) string expression)
{ {
var tagBuilder = new TagBuilder("input"); var tagBuilder = new TagBuilder("input");
tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden)); tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden));
tagBuilder.MergeAttribute("value", "false"); tagBuilder.MergeAttribute("value", "false");
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
tagBuilder.MergeAttribute("name", fullName); tagBuilder.MergeAttribute("name", fullName);
return tagBuilder; return tagBuilder;
@ -202,7 +202,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateHidden( public virtual TagBuilder GenerateHidden(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool useViewData, bool useViewData,
object htmlAttributes) object htmlAttributes)
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
InputType.Hidden, InputType.Hidden,
metadata, metadata,
name, expression,
value, value,
useViewData, useViewData,
isChecked: false, isChecked: false,
@ -233,7 +233,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateLabel( public virtual TagBuilder GenerateLabel(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
[NotNull] ModelMetadata metadata, [NotNull] ModelMetadata metadata,
string name, string expression,
string labelText, string labelText,
object htmlAttributes) object htmlAttributes)
{ {
@ -241,7 +241,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
if (resolvedLabelText == null) if (resolvedLabelText == null)
{ {
resolvedLabelText = resolvedLabelText =
string.IsNullOrEmpty(name) ? string.Empty : name.Split('.').Last(); string.IsNullOrEmpty(expression) ? string.Empty : expression.Split('.').Last();
} }
if (string.IsNullOrEmpty(resolvedLabelText)) if (string.IsNullOrEmpty(resolvedLabelText))
@ -251,7 +251,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var tagBuilder = new TagBuilder("label"); var tagBuilder = new TagBuilder("label");
var idString = var idString =
TagBuilder.CreateSanitizedId(GetFullHtmlFieldName(viewContext, name), IdAttributeDotReplacement); TagBuilder.CreateSanitizedId(GetFullHtmlFieldName(viewContext, expression), IdAttributeDotReplacement);
tagBuilder.Attributes.Add("for", idString); tagBuilder.Attributes.Add("for", idString);
tagBuilder.SetInnerText(resolvedLabelText); tagBuilder.SetInnerText(resolvedLabelText);
tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes), replaceExisting: true); tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes), replaceExisting: true);
@ -263,7 +263,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GeneratePassword( public virtual TagBuilder GeneratePassword(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
object htmlAttributes) object htmlAttributes)
{ {
@ -272,7 +272,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
InputType.Password, InputType.Password,
metadata, metadata,
name, expression,
value, value,
useViewData: false, useViewData: false,
isChecked: false, isChecked: false,
@ -286,7 +286,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateRadioButton( public virtual TagBuilder GenerateRadioButton(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool? isChecked, bool? isChecked,
object htmlAttributes) object htmlAttributes)
@ -301,13 +301,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Note value may be null if isChecked is non-null. // Note value may be null if isChecked is non-null.
if (value == null) if (value == null)
{ {
throw new ArgumentNullException("value"); throw new ArgumentNullException(nameof(value));
} }
// isChecked not provided nor found in the given attributes; fall back to view data. // isChecked not provided nor found in the given attributes; fall back to view data.
var valueString = Convert.ToString(value, CultureInfo.CurrentCulture); var valueString = Convert.ToString(value, CultureInfo.CurrentCulture);
isChecked = !string.IsNullOrEmpty(name) && isChecked = !string.IsNullOrEmpty(expression) &&
string.Equals(EvalString(viewContext, name), valueString, StringComparison.OrdinalIgnoreCase); string.Equals(
EvalString(viewContext, expression),
valueString,
StringComparison.OrdinalIgnoreCase);
} }
} }
else else
@ -334,7 +337,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
InputType.Radio, InputType.Radio,
metadata, metadata,
name, expression,
value, value,
useViewData: false, useViewData: false,
isChecked: isChecked ?? false, isChecked: isChecked ?? false,
@ -363,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string optionLabel, string optionLabel,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
bool allowMultiple, bool allowMultiple,
object htmlAttributes) object htmlAttributes)
@ -373,7 +376,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
metadata, metadata,
optionLabel, optionLabel,
name, expression,
selectList, selectList,
allowMultiple, allowMultiple,
htmlAttributes, htmlAttributes,
@ -385,31 +388,31 @@ namespace Microsoft.AspNet.Mvc.Rendering
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string optionLabel, string optionLabel,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
bool allowMultiple, bool allowMultiple,
object htmlAttributes, object htmlAttributes,
out ICollection<string> selectedValues) out ICollection<string> selectedValues)
{ {
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
if (string.IsNullOrEmpty(fullName)) if (string.IsNullOrEmpty(fullName))
{ {
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression));
} }
// If we got a null selectList, try to use ViewData to get the list of items. // If we got a null selectList, try to use ViewData to get the list of items.
var usedViewData = false; var usedViewData = false;
if (selectList == null) if (selectList == null)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(expression))
{ {
// Avoid ViewData.Eval() throwing an ArgumentException with a different parameter name. Note this // Avoid ViewData.Eval() throwing an ArgumentException with a different parameter name. Note this
// is an extreme case since users must pass a non-null selectList to use CheckBox() or ListBox() // is an extreme case since users must pass a non-null selectList to use CheckBox() or ListBox()
// in a template, where a null or empty name has meaning. // in a template, where a null or empty name has meaning.
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression));
} }
selectList = GetSelectListItems(viewContext, name); selectList = GetSelectListItems(viewContext, expression);
usedViewData = true; usedViewData = true;
} }
@ -418,11 +421,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
// If we haven't already used ViewData to get the entire list of items then we need to // If we haven't already used ViewData to get the entire list of items then we need to
// use the ViewData-supplied value before using the parameter-supplied value. // use the ViewData-supplied value before using the parameter-supplied value.
if (defaultValue == null && !string.IsNullOrEmpty(name)) if (defaultValue == null && !string.IsNullOrEmpty(expression))
{ {
if (!usedViewData) if (!usedViewData)
{ {
defaultValue = viewContext.ViewData.Eval(name); defaultValue = viewContext.ViewData.Eval(expression);
} }
else if (metadata != null) else if (metadata != null)
{ {
@ -465,7 +468,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
} }
tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression));
return tagBuilder; return tagBuilder;
} }
@ -474,25 +477,27 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateTextArea( public virtual TagBuilder GenerateTextArea(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
int rows, int rows,
int columns, int columns,
object htmlAttributes) object htmlAttributes)
{ {
if (rows < 0) if (rows < 0)
{ {
throw new ArgumentOutOfRangeException("rows", Resources.HtmlHelper_TextAreaParameterOutOfRange); throw new ArgumentOutOfRangeException(nameof(rows), Resources.HtmlHelper_TextAreaParameterOutOfRange);
} }
if (columns < 0) if (columns < 0)
{ {
throw new ArgumentOutOfRangeException("columns", Resources.HtmlHelper_TextAreaParameterOutOfRange); throw new ArgumentOutOfRangeException(
nameof(columns),
Resources.HtmlHelper_TextAreaParameterOutOfRange);
} }
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
if (string.IsNullOrEmpty(fullName)) if (string.IsNullOrEmpty(fullName))
{ {
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression));
} }
ModelState modelState; ModelState modelState;
@ -522,7 +527,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
tagBuilder.MergeAttribute("name", fullName, true); tagBuilder.MergeAttribute("name", fullName, true);
tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression));
// If there are any errors for a named field, we add this CSS attribute. // If there are any errors for a named field, we add this CSS attribute.
if (modelState != null && modelState.Errors.Count > 0) if (modelState != null && modelState.Errors.Count > 0)
@ -541,7 +546,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
public virtual TagBuilder GenerateTextBox( public virtual TagBuilder GenerateTextBox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
string format, string format,
object htmlAttributes) object htmlAttributes)
@ -551,7 +556,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewContext, viewContext,
InputType.Text, InputType.Text,
metadata, metadata,
name, expression,
value, value,
useViewData: (metadata == null && value == null), useViewData: (metadata == null && value == null),
isChecked: false, isChecked: false,
@ -564,15 +569,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <inheritdoc /> /// <inheritdoc />
public virtual TagBuilder GenerateValidationMessage( public virtual TagBuilder GenerateValidationMessage(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
string name, string expression,
string message, string message,
string tag, string tag,
object htmlAttributes) object htmlAttributes)
{ {
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
if (string.IsNullOrEmpty(fullName)) if (string.IsNullOrEmpty(fullName))
{ {
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "expression"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression));
} }
var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null; var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null;
@ -721,11 +726,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
public IEnumerable<ModelClientValidationRule> GetClientValidationRules( public IEnumerable<ModelClientValidationRule> GetClientValidationRules(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name) string expression)
{ {
var validatorProvider = _bindingContextAccessor.Value.ValidatorProvider; var validatorProvider = _bindingContextAccessor.Value.ValidatorProvider;
metadata = metadata ?? metadata = metadata ??
ExpressionMetadataProvider.FromStringExpression(name, viewContext.ViewData, _metadataProvider); ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider);
var validationContext = var validationContext =
new ClientModelValidationContext(metadata, _metadataProvider, viewContext.HttpContext.RequestServices); new ClientModelValidationContext(metadata, _metadataProvider, viewContext.HttpContext.RequestServices);
@ -768,9 +773,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder; return tagBuilder;
} }
internal static string GetFullHtmlFieldName(ViewContext viewContext, string name) internal static string GetFullHtmlFieldName(ViewContext viewContext, string expression)
{ {
var fullName = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name); var fullName = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression);
return fullName; return fullName;
} }
@ -827,7 +832,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
InputType inputType, InputType inputType,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool useViewData, bool useViewData,
bool isChecked, bool isChecked,
@ -839,10 +844,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input // Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input
// elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is // elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is
// non-empty. // non-empty.
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
if (string.IsNullOrEmpty(fullName)) if (string.IsNullOrEmpty(fullName))
{ {
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression));
} }
var tagBuilder = new TagBuilder("input"); var tagBuilder = new TagBuilder("input");
@ -920,7 +925,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName); tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);
} }
tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression));
return tagBuilder; return tagBuilder;
} }
@ -946,7 +951,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
protected virtual IDictionary<string, object> GetValidationAttributes( protected virtual IDictionary<string, object> GetValidationAttributes(
ViewContext viewContext, ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name) string expression)
{ {
var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null; var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null;
if (formContext == null) if (formContext == null)
@ -954,14 +959,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
return null; return null;
} }
var fullName = GetFullHtmlFieldName(viewContext, name); var fullName = GetFullHtmlFieldName(viewContext, expression);
if (formContext.RenderedField(fullName)) if (formContext.RenderedField(fullName))
{ {
return null; return null;
} }
formContext.RenderedField(fullName, true); formContext.RenderedField(fullName, true);
var clientRules = GetClientValidationRules(viewContext, metadata, name); var clientRules = GetClientValidationRules(viewContext, metadata, expression);
return UnobtrusiveValidationAttributesGenerator.GetValidationAttributes(clientRules); return UnobtrusiveValidationAttributesGenerator.GetValidationAttributes(clientRules);
} }
@ -1011,20 +1016,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
} }
private static IEnumerable<SelectListItem> GetSelectListItems([NotNull] ViewContext viewContext, string name) private static IEnumerable<SelectListItem> GetSelectListItems(
[NotNull] ViewContext viewContext,
string expression)
{ {
var value = viewContext.ViewData.Eval(name); var value = viewContext.ViewData.Eval(expression);
if (value == null) if (value == null)
{ {
throw new InvalidOperationException(Resources.FormatHtmlHelper_MissingSelectData( throw new InvalidOperationException(Resources.FormatHtmlHelper_MissingSelectData(
"IEnumerable<SelectListItem>", name)); "IEnumerable<SelectListItem>", expression));
} }
var selectList = value as IEnumerable<SelectListItem>; var selectList = value as IEnumerable<SelectListItem>;
if (selectList == null) if (selectList == null)
{ {
throw new InvalidOperationException(Resources.FormatHtmlHelper_WrongSelectDataType( throw new InvalidOperationException(Resources.FormatHtmlHelper_WrongSelectDataType(
name, value.GetType().FullName, "IEnumerable<SelectListItem>")); expression, value.GetType().FullName, "IEnumerable<SelectListItem>"));
} }
return selectList; return selectList;

View File

@ -113,18 +113,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// value to the dictionary. It will expose public properties from derived types as well. This is typically /// value to the dictionary. It will expose public properties from derived types as well. This is typically
/// used with objects of an anonymous type. /// used with objects of an anonymous type.
/// ///
/// If the object is already an <see cref="IDictionary{string, object}"/> instance, then it is /// If the <paramref name="value"/> is already an <see cref="IDictionary{string, object}"/> instance, then it
/// returned as-is. /// is returned as-is.
/// <example> /// <example>
/// <c>new { data_name="value" }</c> will translate to the entry <c>{ "data_name", "value" }</c> /// <c>new { data_name="value" }</c> will translate to the entry <c>{ "data_name", "value" }</c>
/// in the resulting dictionary. /// in the resulting dictionary.
/// </example> /// </example>
/// </summary> /// </summary>
/// <param name="obj">The object to be converted.</param> /// <param name="value">The <see cref="object"/> to be converted.</param>
/// <returns>The created dictionary of property names and property values.</returns> /// <returns>The created dictionary of property names and property values.</returns>
public static IDictionary<string, object> ObjectToDictionary(object obj) public static IDictionary<string, object> ObjectToDictionary(object value)
{ {
return TypeHelper.ObjectToDictionary(obj); return TypeHelper.ObjectToDictionary(value);
} }
/// <summary> /// <summary>
@ -231,9 +231,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes) public HtmlString CheckBox(string expression, bool? isChecked, object htmlAttributes)
{ {
return GenerateCheckBox(metadata: null, name: name, isChecked: isChecked, htmlAttributes: htmlAttributes); return GenerateCheckBox(
metadata: null,
expression: expression,
isChecked: isChecked,
htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -255,9 +259,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string GenerateIdFromName([NotNull] string name) public string GenerateIdFromName([NotNull] string fullName)
{ {
return TagBuilder.CreateSanitizedId(name, IdAttributeDotReplacement); return TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -282,26 +286,32 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string DisplayText(string name) public string DisplayText(string expression)
{ {
var metadata = ExpressionMetadataProvider.FromStringExpression(name, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
return GenerateDisplayText(metadata); return GenerateDisplayText(metadata);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString DropDownList(string name, IEnumerable<SelectListItem> selectList, string optionLabel, public HtmlString DropDownList(
string expression,
IEnumerable<SelectListItem> selectList,
string optionLabel,
object htmlAttributes) object htmlAttributes)
{ {
return GenerateDropDown( return GenerateDropDown(
metadata: null, metadata: null,
expression: name, expression: expression,
selectList: selectList, selectList: selectList,
optionLabel: optionLabel, optionLabel: optionLabel,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString Editor(string expression, string templateName, string htmlFieldName, public HtmlString Editor(
string expression,
string templateName,
string htmlFieldName,
object additionalViewData) object additionalViewData)
{ {
var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
@ -314,16 +324,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString Hidden(string name, object value, object htmlAttributes) public HtmlString Hidden(string expression, object value, object htmlAttributes)
{ {
return GenerateHidden(metadata: null, name: name, value: value, useViewData: (value == null), return GenerateHidden(
metadata: null,
expression: expression,
value: value,
useViewData: (value == null),
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public string Id(string name) public string Id(string expression)
{ {
return GenerateId(name); return GenerateId(expression);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -331,27 +345,33 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
return GenerateLabel( return GenerateLabel(
metadata, metadata,
expression, expression,
labelText, labelText,
htmlAttributes); htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString ListBox(string name, IEnumerable<SelectListItem> selectList, object htmlAttributes) public HtmlString ListBox(string expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
{ {
return GenerateListBox(metadata: null, name: name, selectList: selectList, htmlAttributes: htmlAttributes); return GenerateListBox(
metadata: null,
expression: expression,
selectList: selectList,
htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public string Name(string name) public string Name(string expression)
{ {
return GenerateName(name); return GenerateName(expression);
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<HtmlString> PartialAsync([NotNull] string partialViewName, object model, public async Task<HtmlString> PartialAsync(
ViewDataDictionary viewData) [NotNull] string partialViewName,
object model,
ViewDataDictionary viewData)
{ {
using (var writer = new StringCollectionTextWriter(Encoding.UTF8)) using (var writer = new StringCollectionTextWriter(Encoding.UTF8))
{ {
@ -419,15 +439,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString Password(string name, object value, object htmlAttributes) public HtmlString Password(string expression, object value, object htmlAttributes)
{ {
return GeneratePassword(metadata: null, name: name, value: value, htmlAttributes: htmlAttributes); return GeneratePassword(
metadata: null,
expression: expression,
value: value,
htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes) public HtmlString RadioButton(string expression, object value, bool? isChecked, object htmlAttributes)
{ {
return GenerateRadioButton(metadata: null, name: name, value: value, isChecked: isChecked, return GenerateRadioButton(
metadata: null,
expression: expression,
value: value,
isChecked: isChecked,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
} }
@ -504,28 +532,28 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString TextArea(string name, string value, int rows, int columns, object htmlAttributes) public HtmlString TextArea(string expression, string value, int rows, int columns, object htmlAttributes)
{ {
var metadata = ExpressionMetadataProvider.FromStringExpression(name, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider);
if (value != null) if (value != null)
{ {
metadata.Model = value; metadata.Model = value;
} }
return GenerateTextArea(metadata, name, rows, columns, htmlAttributes); return GenerateTextArea(metadata, expression, rows, columns, htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString TextBox(string name, object value, string format, object htmlAttributes) public HtmlString TextBox(string expression, object value, string format, object htmlAttributes)
{ {
return GenerateTextBox(metadata: null, name: name, value: value, format: format, return GenerateTextBox(metadata: null, expression: expression, value: value, format: format,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public string Value(string name, string format) public string Value(string expression, string format)
{ {
return GenerateValue(name, value: null, format: format, useViewData: true); return GenerateValue(expression, value: null, format: format, useViewData: true);
} }
/// <summary> /// <summary>
@ -538,16 +566,19 @@ namespace Microsoft.AspNet.Mvc.Rendering
return new MvcForm(ViewContext); return new MvcForm(ViewContext);
} }
protected virtual HtmlString GenerateCheckBox(ModelMetadata metadata, string name, bool? isChecked, protected virtual HtmlString GenerateCheckBox(
ModelMetadata metadata,
string expression,
bool? isChecked,
object htmlAttributes) object htmlAttributes)
{ {
var checkbox = _htmlGenerator.GenerateCheckBox( var checkbox = _htmlGenerator.GenerateCheckBox(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
isChecked, isChecked,
htmlAttributes); htmlAttributes);
var hidden = _htmlGenerator.GenerateHiddenForCheckbox(ViewContext, metadata, name); var hidden = _htmlGenerator.GenerateHiddenForCheckbox(ViewContext, metadata, expression);
if (checkbox == null || hidden == null) if (checkbox == null || hidden == null)
{ {
return HtmlString.Empty; return HtmlString.Empty;
@ -558,7 +589,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
return new HtmlString(elements); return new HtmlString(elements);
} }
protected virtual string GenerateDisplayName([NotNull] ModelMetadata metadata, string htmlFieldName) protected virtual string GenerateDisplayName([NotNull] ModelMetadata metadata, string expression)
{ {
// We don't call ModelMetadata.GetDisplayName here because // We don't call ModelMetadata.GetDisplayName here because
// we want to fall back to the field name rather than the ModelType. // we want to fall back to the field name rather than the ModelType.
@ -567,7 +598,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
if (resolvedDisplayName == null) if (resolvedDisplayName == null)
{ {
resolvedDisplayName = resolvedDisplayName =
string.IsNullOrEmpty(htmlFieldName) ? string.Empty : htmlFieldName.Split('.').Last(); string.IsNullOrEmpty(expression) ? string.Empty : expression.Split('.').Last();
} }
return resolvedDisplayName; return resolvedDisplayName;
@ -578,14 +609,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
return metadata.SimpleDisplayText ?? string.Empty; return metadata.SimpleDisplayText ?? string.Empty;
} }
protected HtmlString GenerateDropDown(ModelMetadata metadata, string expression, protected HtmlString GenerateDropDown(
IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes) ModelMetadata metadata,
string expression,
IEnumerable<SelectListItem> selectList,
string optionLabel,
object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GenerateSelect( var tagBuilder = _htmlGenerator.GenerateSelect(
ViewContext, ViewContext,
metadata, metadata,
optionLabel, optionLabel,
name: expression, expression: expression,
selectList: selectList, selectList: selectList,
allowMultiple: false, allowMultiple: false,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
@ -597,7 +632,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.Normal); return tagBuilder.ToHtmlString(TagRenderMode.Normal);
} }
protected virtual HtmlString GenerateEditor(ModelMetadata metadata, string htmlFieldName, string templateName, protected virtual HtmlString GenerateEditor(
ModelMetadata metadata,
string htmlFieldName,
string templateName,
object additionalViewData) object additionalViewData)
{ {
var templateBuilder = new TemplateBuilder( var templateBuilder = new TemplateBuilder(
@ -704,7 +742,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
protected virtual HtmlString GenerateHidden( protected virtual HtmlString GenerateHidden(
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool useViewData, bool useViewData,
object htmlAttributes) object htmlAttributes)
@ -713,7 +751,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
_htmlGenerator.GenerateHidden( _htmlGenerator.GenerateHidden(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
value, value,
useViewData, useViewData,
htmlAttributes); htmlAttributes);
@ -727,21 +765,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
protected virtual string GenerateId(string expression) protected virtual string GenerateId(string expression)
{ {
var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name: expression); var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression: expression);
var id = TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); var id = TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement);
return id; return id;
} }
protected virtual HtmlString GenerateLabel([NotNull] ModelMetadata metadata, protected virtual HtmlString GenerateLabel(
string htmlFieldName, [NotNull] ModelMetadata metadata,
string labelText, string expression,
object htmlAttributes) string labelText,
object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GenerateLabel( var tagBuilder = _htmlGenerator.GenerateLabel(
ViewContext, ViewContext,
metadata, metadata,
name: htmlFieldName, expression: expression,
labelText: labelText, labelText: labelText,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
if (tagBuilder == null) if (tagBuilder == null)
@ -754,7 +793,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
protected HtmlString GenerateListBox( protected HtmlString GenerateListBox(
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
object htmlAttributes) object htmlAttributes)
{ {
@ -762,7 +801,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
ViewContext, ViewContext,
metadata, metadata,
optionLabel: null, optionLabel: null,
name: name, expression: expression,
selectList: selectList, selectList: selectList,
allowMultiple: true, allowMultiple: true,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
@ -774,19 +813,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.Normal); return tagBuilder.ToHtmlString(TagRenderMode.Normal);
} }
protected virtual string GenerateName(string name) protected virtual string GenerateName(string expression)
{ {
var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name); var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression);
return fullName; return fullName;
} }
protected virtual HtmlString GeneratePassword(ModelMetadata metadata, string name, object value, protected virtual HtmlString GeneratePassword(
ModelMetadata metadata,
string expression,
object value,
object htmlAttributes) object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GeneratePassword( var tagBuilder = _htmlGenerator.GeneratePassword(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
value, value,
htmlAttributes); htmlAttributes);
if (tagBuilder == null) if (tagBuilder == null)
@ -797,13 +839,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing);
} }
protected virtual HtmlString GenerateRadioButton(ModelMetadata metadata, string name, object value, protected virtual HtmlString GenerateRadioButton(
bool? isChecked, object htmlAttributes) ModelMetadata metadata,
string expression,
object value,
bool? isChecked,
object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GenerateRadioButton( var tagBuilder = _htmlGenerator.GenerateRadioButton(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
value, value,
isChecked, isChecked,
htmlAttributes); htmlAttributes);
@ -815,13 +861,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing);
} }
protected virtual HtmlString GenerateTextArea(ModelMetadata metadata, string name, protected virtual HtmlString GenerateTextArea(
int rows, int columns, object htmlAttributes) ModelMetadata metadata,
string expression,
int rows,
int columns,
object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GenerateTextArea( var tagBuilder = _htmlGenerator.GenerateTextArea(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
rows, rows,
columns, columns,
htmlAttributes); htmlAttributes);
@ -833,13 +883,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.Normal); return tagBuilder.ToHtmlString(TagRenderMode.Normal);
} }
protected virtual HtmlString GenerateTextBox(ModelMetadata metadata, string name, object value, string format, protected virtual HtmlString GenerateTextBox(
ModelMetadata metadata,
string expression,
object value,
string format,
object htmlAttributes) object htmlAttributes)
{ {
var tagBuilder = _htmlGenerator.GenerateTextBox( var tagBuilder = _htmlGenerator.GenerateTextBox(
ViewContext, ViewContext,
metadata, metadata,
name, expression,
value, value,
format, format,
htmlAttributes); htmlAttributes);
@ -851,14 +905,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing);
} }
protected virtual HtmlString GenerateValidationMessage(string expression, protected virtual HtmlString GenerateValidationMessage(
string expression,
string message, string message,
object htmlAttributes, object htmlAttributes,
string tag) string tag)
{ {
var tagBuilder = _htmlGenerator.GenerateValidationMessage( var tagBuilder = _htmlGenerator.GenerateValidationMessage(
ViewContext, ViewContext,
name: expression, expression: expression,
message: message, message: message,
tag: tag, tag: tag,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
@ -890,9 +945,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.Normal); return tagBuilder.ToHtmlString(TagRenderMode.Normal);
} }
protected virtual string GenerateValue(string name, object value, string format, bool useViewData) protected virtual string GenerateValue(string expression, object value, string format, bool useViewData)
{ {
var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name); var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression);
var attemptedValue = var attemptedValue =
(string)DefaultHtmlGenerator.GetModelStateValue(ViewContext, fullName, typeof(string)); (string)DefaultHtmlGenerator.GetModelStateValue(ViewContext, fullName, typeof(string));
@ -904,7 +959,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
else if (useViewData) else if (useViewData)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(expression))
{ {
// case 2(a): format the value from ModelMetadata for the current model // case 2(a): format the value from ModelMetadata for the current model
var metadata = ViewData.ModelMetadata; var metadata = ViewData.ModelMetadata;
@ -913,7 +968,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
else else
{ {
// case 2(b): format the value from ViewData // case 2(b): format the value from ViewData
resolvedValue = DefaultHtmlGenerator.EvalString(ViewContext, name, format); resolvedValue = DefaultHtmlGenerator.EvalString(ViewContext, expression, format);
} }
} }
else else
@ -928,9 +983,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <inheritdoc /> /// <inheritdoc />
public IEnumerable<ModelClientValidationRule> GetClientValidationRules( public IEnumerable<ModelClientValidationRule> GetClientValidationRules(
ModelMetadata metadata, ModelMetadata metadata,
string name) string expression)
{ {
return _htmlGenerator.GetClientValidationRules(ViewContext, metadata, name); return _htmlGenerator.GetClientValidationRules(ViewContext, metadata, expression);
} }
} }
} }

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull(
"ViewData", "ViewData",
typeof(ViewContext)), typeof(ViewContext)),
"viewContext"); nameof(viewContext));
} }
ViewData = viewContext.ViewData as ViewDataDictionary<TModel>; ViewData = viewContext.ViewData as ViewDataDictionary<TModel>;
@ -44,14 +44,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
"ViewData", "ViewData",
viewContext.ViewData.GetType().FullName, viewContext.ViewData.GetType().FullName,
typeof(ViewDataDictionary<TModel>).FullName), typeof(ViewDataDictionary<TModel>).FullName),
"viewContext"); nameof(viewContext));
} }
base.Contextualize(viewContext); base.Contextualize(viewContext);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString CheckBoxFor([NotNull] Expression<Func<TModel, bool>> expression, public HtmlString CheckBoxFor(
[NotNull] Expression<Func<TModel, bool>> expression,
object htmlAttributes) object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
@ -60,8 +61,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString DropDownListFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString DropDownListFor<TResult>(
IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes) [NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList,
string optionLabel,
object htmlAttributes)
{ {
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
@ -70,10 +74,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString DisplayFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression, public HtmlString DisplayFor<TResult>(
string templateName, [NotNull] Expression<Func<TModel, TResult>> expression,
string htmlFieldName, string templateName,
object additionalViewData) string htmlFieldName,
object additionalViewData)
{ {
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression,
ViewData, ViewData,
@ -86,17 +91,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string DisplayNameFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression) public string DisplayNameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
return GenerateDisplayName(metadata, ExpressionHelper.GetExpressionText(expression)); return GenerateDisplayName(metadata, ExpressionHelper.GetExpressionText(expression));
} }
/// <inheritdoc /> /// <inheritdoc />
public string DisplayNameForInnerType<TModelItem, TValue>( public string DisplayNameForInnerType<TModelItem, TResult>(
[NotNull] Expression<Func<TModelItem, TValue>> expression) [NotNull] Expression<Func<TModelItem, TResult>> expression)
{ {
var metadata = ExpressionMetadataProvider.FromLambdaExpression<TModelItem, TValue>( var metadata = ExpressionMetadataProvider.FromLambdaExpression<TModelItem, TResult>(
expression, expression,
new ViewDataDictionary<TModelItem>(ViewData, model: null), new ViewDataDictionary<TModelItem>(ViewData, model: null),
MetadataProvider); MetadataProvider);
@ -111,14 +116,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string DisplayTextFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression) public string DisplayTextFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return GenerateDisplayText(GetModelMetadata(expression)); return GenerateDisplayText(GetModelMetadata(expression));
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString EditorFor<TValue>( public HtmlString EditorFor<TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
string templateName, string templateName,
string htmlFieldName, string htmlFieldName,
object additionalViewData) object additionalViewData)
@ -133,7 +138,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString HiddenFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString HiddenFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes) object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
@ -142,14 +148,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string IdFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression) public string IdFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return GenerateId(GetExpressionName(expression)); return GenerateId(GetExpressionName(expression));
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString LabelFor<TValue>( public HtmlString LabelFor<TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
string labelText, string labelText,
object htmlAttributes) object htmlAttributes)
{ {
@ -158,8 +164,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString ListBoxFor<TProperty>( public HtmlString ListBoxFor<TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
object htmlAttributes) object htmlAttributes)
{ {
@ -170,14 +176,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string NameFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression) public string NameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
var expressionName = GetExpressionName(expression); var expressionName = GetExpressionName(expression);
return Name(expressionName); return Name(expressionName);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString PasswordFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString PasswordFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes) object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
@ -186,8 +193,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString RadioButtonFor<TProperty>( public HtmlString RadioButtonFor<TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
[NotNull] object value, [NotNull] object value,
object htmlAttributes) object htmlAttributes)
{ {
@ -197,27 +204,32 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString TextAreaFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, int rows, public HtmlString TextAreaFor<TResult>(
int columns, object htmlAttributes) [NotNull] Expression<Func<TModel, TResult>> expression,
int rows,
int columns,
object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
return GenerateTextArea(metadata, GetExpressionName(expression), rows, columns, htmlAttributes); return GenerateTextArea(metadata, GetExpressionName(expression), rows, columns, htmlAttributes);
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString TextBoxFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString TextBoxFor<TResult>(
string format, object htmlAttributes) [NotNull] Expression<Func<TModel, TResult>> expression,
string format,
object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
return GenerateTextBox(metadata, GetExpressionName(expression), metadata.Model, format, htmlAttributes); return GenerateTextBox(metadata, GetExpressionName(expression), metadata.Model, format, htmlAttributes);
} }
protected string GetExpressionName<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression) protected string GetExpressionName<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return ExpressionHelper.GetExpressionText(expression); return ExpressionHelper.GetExpressionText(expression);
} }
protected ModelMetadata GetModelMetadata<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression) protected ModelMetadata GetModelMetadata<TResult>([NotNull] Expression<Func<TModel, TResult>> expression)
{ {
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider); var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider);
if (metadata == null) if (metadata == null)
@ -230,7 +242,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString ValidationMessageFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString ValidationMessageFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
string message, string message,
object htmlAttributes, object htmlAttributes,
string tag) string tag)
@ -242,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public string ValueFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, string format) public string ValueFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression, string format)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
return GenerateValue(ExpressionHelper.GetExpressionText(expression), metadata.Model, format, return GenerateValue(ExpressionHelper.GetExpressionText(expression), metadata.Model, format,

View File

@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateCheckBox( TagBuilder GenerateCheckBox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
bool? isChecked, bool? isChecked,
object htmlAttributes); object htmlAttributes);
@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateHiddenForCheckbox( TagBuilder GenerateHiddenForCheckbox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name); string expression);
/// <summary> /// <summary>
/// Generate a &lt;form&gt; element. When the user submits the form, the action with name /// Generate a &lt;form&gt; element. When the user submits the form, the action with name
@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateHidden( TagBuilder GenerateHidden(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool useViewData, bool useViewData,
object htmlAttributes); object htmlAttributes);
@ -115,21 +115,21 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateLabel( TagBuilder GenerateLabel(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
[NotNull] ModelMetadata metadata, [NotNull] ModelMetadata metadata,
string name, string expression,
string labelText, string labelText,
object htmlAttributes); object htmlAttributes);
TagBuilder GeneratePassword( TagBuilder GeneratePassword(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
object htmlAttributes); object htmlAttributes);
TagBuilder GenerateRadioButton( TagBuilder GenerateRadioButton(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
bool? isChecked, bool? isChecked,
object htmlAttributes); object htmlAttributes);
@ -147,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string optionLabel, string optionLabel,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
bool allowMultiple, bool allowMultiple,
object htmlAttributes); object htmlAttributes);
@ -156,7 +156,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string optionLabel, string optionLabel,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
bool allowMultiple, bool allowMultiple,
object htmlAttributes, object htmlAttributes,
@ -165,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateTextArea( TagBuilder GenerateTextArea(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
int rows, int rows,
int columns, int columns,
object htmlAttributes); object htmlAttributes);
@ -173,14 +173,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
TagBuilder GenerateTextBox( TagBuilder GenerateTextBox(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name, string expression,
object value, object value,
string format, string format,
object htmlAttributes); object htmlAttributes);
TagBuilder GenerateValidationMessage( TagBuilder GenerateValidationMessage(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
string name, string expression,
string message, string message,
string tag, string tag,
object htmlAttributes); object htmlAttributes);
@ -193,11 +193,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
object htmlAttributes); object htmlAttributes);
/// <remarks> /// <remarks>
/// Not used directly in HtmlHelper. Exposed publicly for use in other IHtmlHelper implementations. /// Not used directly in <see cref="HtmlHelper"/>. Exposed publicly for use in other <see cref="IHtmlHelper"/>
/// implementations.
/// </remarks> /// </remarks>
IEnumerable<ModelClientValidationRule> GetClientValidationRules( IEnumerable<ModelClientValidationRule> GetClientValidationRules(
[NotNull] ViewContext viewContext, [NotNull] ViewContext viewContext,
ModelMetadata metadata, ModelMetadata metadata,
string name); string expression);
} }
} }

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns HTML markup for the <paramref name="expression"/>, using a display template. The template is found /// Returns HTML markup for the <paramref name="expression"/>, using a display template. The template is found
/// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to display. /// <see cref="object"/> that contains the properties to display.
@ -35,9 +35,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Display([NotNull] this IHtmlHelper html, string expression) public static HtmlString Display([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null); return htmlHelper.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="expression"/>'s /// additional view data. The template is found using the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to display. /// <see cref="object"/> that contains the properties to display.
@ -71,11 +71,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
object additionalViewData) object additionalViewData)
{ {
return html.Display(expression, templateName: null, htmlFieldName: null, return htmlHelper.Display(
expression,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -84,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s /// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to display. /// <see cref="object"/> that contains the properties to display.
@ -106,11 +109,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string templateName) string templateName)
{ {
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: null); return htmlHelper.Display(expression, templateName, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -118,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the /// additional view data. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to display. /// <see cref="object"/> that contains the properties to display.
@ -145,12 +148,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string templateName, string templateName,
object additionalViewData) object additionalViewData)
{ {
return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); return htmlHelper.Display(
expression,
templateName,
htmlFieldName: null,
additionalViewData: additionalViewData);
} }
/// <summary> /// <summary>
@ -158,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// field name. The template is found using the <paramref name="templateName"/> or the /// field name. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s<see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s<see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to display. /// <see cref="object"/> that contains the properties to display.
@ -184,22 +191,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Display( public static HtmlString Display(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string templateName, string templateName,
string htmlFieldName) string htmlFieldName)
{ {
return html.Display(expression, templateName, htmlFieldName, additionalViewData: null); return htmlHelper.Display(expression, templateName, htmlFieldName, additionalViewData: null);
} }
/// <summary> /// <summary>
/// Returns HTML markup for the <paramref name="expression"/>, using a display template. The template is found /// Returns HTML markup for the <paramref name="expression"/>, using a display template. The template is found
/// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -211,10 +218,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null, return htmlHelper.DisplayFor<TResult>(
expression,
templateName: null,
htmlFieldName: null,
additionalViewData: null); additionalViewData: null);
} }
@ -223,7 +234,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="expression"/>'s /// additional view data. The template is found using the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
@ -231,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// instance created for the template. /// instance created for the template.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -243,11 +254,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
object additionalViewData) [NotNull] Expression<Func<TModel, TResult>> expression,
object additionalViewData)
{ {
return html.DisplayFor<TValue>(expression, templateName: null, htmlFieldName: null, return htmlHelper.DisplayFor<TResult>(
expression,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -256,11 +271,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s /// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -272,11 +287,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
string templateName) [NotNull] Expression<Func<TModel, TResult>> expression,
string templateName)
{ {
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null, additionalViewData: null); return htmlHelper.DisplayFor<TResult>(
expression,
templateName,
htmlFieldName: null,
additionalViewData: null);
} }
/// <summary> /// <summary>
@ -284,7 +304,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the /// additional view data. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
@ -293,7 +313,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// instance created for the template. /// instance created for the template.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -305,12 +325,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
string templateName, [NotNull] Expression<Func<TModel, TResult>> expression,
object additionalViewData) string templateName,
object additionalViewData)
{ {
return html.DisplayFor<TValue>(expression, templateName, htmlFieldName: null, return htmlHelper.DisplayFor<TResult>(
expression,
templateName,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -319,7 +343,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// field name. The template is found using the <paramref name="templateName"/> or the /// field name. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
@ -327,7 +351,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// that have the same name. /// that have the same name.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -339,12 +363,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString DisplayFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
string templateName, [NotNull] Expression<Func<TModel, TResult>> expression,
string htmlFieldName) string templateName,
string htmlFieldName)
{ {
return html.DisplayFor<TValue>(expression, templateName: templateName, htmlFieldName: htmlFieldName, return htmlHelper.DisplayFor<TResult>(
expression,
templateName: templateName,
htmlFieldName: htmlFieldName,
additionalViewData: null); additionalViewData: null);
} }
@ -352,7 +380,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns HTML markup for the current model, using a display template. The template is found using the /// Returns HTML markup for the current model, using a display template. The template is found using the
/// model's <see cref="ModelBinding.ModelMetadata"/>. /// model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -364,16 +392,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return html.Display(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); return htmlHelper.Display(
expression: null,
templateName: null,
htmlFieldName: null,
additionalViewData: null);
} }
/// <summary> /// <summary>
/// Returns HTML markup for the current model, using a display template and specified additional view data. The /// Returns HTML markup for the current model, using a display template and specified additional view data. The
/// template is found using the model's <see cref="ModelBinding.ModelMetadata"/>. /// template is found using the model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> /// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
@ -390,9 +422,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData)
{ {
return html.Display(expression: null, templateName: null, htmlFieldName: null, return htmlHelper.Display(
expression: null,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -400,7 +435,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns HTML markup for the current model, using a display template. The template is found using the /// Returns HTML markup for the current model, using a display template. The template is found using the
/// <paramref name="templateName"/> or the model's <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="templateName"/> or the model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
@ -413,9 +448,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName) public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper, string templateName)
{ {
return html.Display(expression: null, templateName: templateName, htmlFieldName: null, return htmlHelper.Display(
expression: null,
templateName: templateName,
htmlFieldName: null,
additionalViewData: null); additionalViewData: null);
} }
@ -424,7 +462,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// template is found using the <paramref name="templateName"/> or the model's /// template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
@ -443,11 +481,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string templateName, string templateName,
object additionalViewData) object additionalViewData)
{ {
return html.Display(expression: null, templateName: templateName, htmlFieldName: null, return htmlHelper.Display(
expression: null,
templateName: templateName,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -456,7 +497,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// template is found using the <paramref name="templateName"/> or the model's /// template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
/// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for /// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for
@ -474,11 +515,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string templateName, string templateName,
string htmlFieldName) string htmlFieldName)
{ {
return html.Display(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, return htmlHelper.Display(
expression: null,
templateName: templateName,
htmlFieldName: htmlFieldName,
additionalViewData: null); additionalViewData: null);
} }
@ -487,7 +531,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the model's /// additional view data. The template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
/// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for /// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for
@ -510,12 +554,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString DisplayForModel( public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string templateName, string templateName,
string htmlFieldName, string htmlFieldName,
object additionalViewData) object additionalViewData)
{ {
return html.Display(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, return htmlHelper.Display(
expression: null,
templateName: templateName,
htmlFieldName: htmlFieldName,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
} }

View File

@ -31,13 +31,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <param name="expression">An expression to be evaluated against an item in the current model.</param> /// <param name="expression">An expression to be evaluated against an item in the current model.</param>
/// <typeparam name="TModelItem">The type of items in the model collection.</typeparam> /// <typeparam name="TModelItem">The type of items in the model collection.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the display name.</returns> /// <returns>A <see cref="string"/> containing the display name.</returns>
public static string DisplayNameFor<TModelItem, TValue>( public static string DisplayNameFor<TModelItem, TResult>(
[NotNull] this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper, [NotNull] this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper,
[NotNull] Expression<Func<TModelItem, TValue>> expression) [NotNull] Expression<Func<TModelItem, TResult>> expression)
{ {
return htmlHelper.DisplayNameForInnerType<TModelItem, TValue>(expression); return htmlHelper.DisplayNameForInnerType<TModelItem, TResult>(expression);
} }
} }
} }

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns HTML markup for the <paramref name="expression"/>, using an editor template. The template is found /// Returns HTML markup for the <paramref name="expression"/>, using an editor template. The template is found
/// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to edit. /// <see cref="object"/> that contains the properties to edit.
@ -35,9 +35,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression) public static HtmlString Editor([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return html.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); return htmlHelper.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="expression"/>'s /// additional view data. The template is found using the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to edit. /// <see cref="object"/> that contains the properties to edit.
@ -70,9 +70,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData) public static HtmlString Editor(
[NotNull] this IHtmlHelper htmlHelper,
string expression,
object additionalViewData)
{ {
return html.Editor(expression, templateName: null, htmlFieldName: null, return htmlHelper.Editor(
expression,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -81,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s /// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to edit. /// <see cref="object"/> that contains the properties to edit.
@ -102,9 +108,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName) public static HtmlString Editor([NotNull] this IHtmlHelper htmlHelper, string expression, string templateName)
{ {
return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null); return htmlHelper.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -112,7 +118,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the /// additional view data. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to edit. /// <see cref="object"/> that contains the properties to edit.
@ -138,10 +144,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, public static HtmlString Editor(
[NotNull] this IHtmlHelper htmlHelper,
string expression,
string templateName,
object additionalViewData) object additionalViewData)
{ {
return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); return htmlHelper.Editor(
expression,
templateName,
htmlFieldName: null,
additionalViewData: additionalViewData);
} }
/// <summary> /// <summary>
@ -149,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// field name. The template is found using the <paramref name="templateName"/> or the /// field name. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression"> /// <param name="expression">
/// Expression name, relative to the current model. May identify a single property or an /// Expression name, relative to the current model. May identify a single property or an
/// <see cref="object"/> that contains the properties to edit. /// <see cref="object"/> that contains the properties to edit.
@ -174,20 +187,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, public static HtmlString Editor(
[NotNull] this IHtmlHelper htmlHelper,
string expression,
string templateName,
string htmlFieldName) string htmlFieldName)
{ {
return html.Editor(expression, templateName, htmlFieldName, additionalViewData: null); return htmlHelper.Editor(expression, templateName, htmlFieldName, additionalViewData: null);
} }
/// <summary> /// <summary>
/// Returns HTML markup for the <paramref name="expression"/>, using an editor template. The template is found /// Returns HTML markup for the <paramref name="expression"/>, using an editor template. The template is found
/// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// using the <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -199,10 +215,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return html.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); return htmlHelper.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -210,7 +227,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="expression"/>'s /// additional view data. The template is found using the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
@ -218,7 +235,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// instance created for the template. /// instance created for the template.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -230,10 +247,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, object additionalViewData) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
object additionalViewData)
{ {
return html.EditorFor(expression, templateName: null, htmlFieldName: null, return htmlHelper.EditorFor(
expression,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -242,11 +264,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s /// using the <paramref name="templateName"/> or the <paramref name="expression"/>'s
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template that is used to create the HTML markup.</param> /// <param name="templateName">The name of the template that is used to create the HTML markup.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -258,10 +280,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string templateName)
{ {
return html.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null); return htmlHelper.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null);
} }
/// <summary> /// <summary>
@ -269,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the /// additional view data. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template that is used to create the HTML markup.</param> /// <param name="templateName">The name of the template that is used to create the HTML markup.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
@ -278,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// instance created for the template. /// instance created for the template.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -290,10 +314,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string templateName,
object additionalViewData)
{ {
return html.EditorFor(expression, templateName, htmlFieldName: null, return htmlHelper.EditorFor(
expression,
templateName,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -302,7 +332,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// field name. The template is found using the <paramref name="templateName"/> or the /// field name. The template is found using the <paramref name="templateName"/> or the
/// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="expression"/>'s <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="templateName">The name of the template that is used to create the HTML markup.</param> /// <param name="templateName">The name of the template that is used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
@ -310,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// that have the same name. /// that have the same name.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -322,17 +352,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString EditorFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string templateName,
string htmlFieldName)
{ {
return html.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null); return htmlHelper.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null);
} }
/// <summary> /// <summary>
/// Returns HTML markup for the current model, using an editor template. The template is found using the /// Returns HTML markup for the current model, using an editor template. The template is found using the
/// model's <see cref="ModelBinding.ModelMetadata"/>. /// model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -344,16 +377,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html) public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return html.Editor(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); return htmlHelper.Editor(
expression: null,
templateName: null,
htmlFieldName: null,
additionalViewData: null);
} }
/// <summary> /// <summary>
/// Returns HTML markup for the current model, using an editor template and specified additional view data. The /// Returns HTML markup for the current model, using an editor template and specified additional view data. The
/// template is found using the model's <see cref="ModelBinding.ModelMetadata"/>. /// template is found using the model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
/// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> /// that can contain additional view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/>
@ -370,9 +407,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData) public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData)
{ {
return html.Editor(expression: null, templateName: null, htmlFieldName: null, return htmlHelper.Editor(
expression: null,
templateName: null,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -380,7 +420,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns HTML markup for the current model, using an editor template. The template is found using the /// Returns HTML markup for the current model, using an editor template. The template is found using the
/// <paramref name="templateName"/> or the model's <see cref="ModelBinding.ModelMetadata"/>. /// <paramref name="templateName"/> or the model's <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
@ -393,9 +433,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName) public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper, string templateName)
{ {
return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, return htmlHelper.Editor(
expression: null,
templateName: templateName,
htmlFieldName: null,
additionalViewData: null); additionalViewData: null);
} }
@ -404,7 +447,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// template is found using the <paramref name="templateName"/> or the model's /// template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="additionalViewData"> /// <param name="additionalViewData">
/// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/> /// An anonymous <see cref="object"/> or <see cref="System.Collections.Generic.IDictionary{string, object}"/>
@ -422,10 +465,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel(
[NotNull] this IHtmlHelper htmlHelper,
string templateName,
object additionalViewData) object additionalViewData)
{ {
return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, return htmlHelper.Editor(
expression: null,
templateName: templateName,
htmlFieldName: null,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
@ -434,7 +482,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// template is found using the <paramref name="templateName"/> or the model's /// template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
/// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for /// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for
@ -451,10 +499,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel(
[NotNull] this IHtmlHelper htmlHelper,
string templateName,
string htmlFieldName) string htmlFieldName)
{ {
return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, return htmlHelper.Editor(
expression: null,
templateName: templateName,
htmlFieldName: htmlFieldName,
additionalViewData: null); additionalViewData: null);
} }
@ -463,7 +516,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// additional view data. The template is found using the <paramref name="templateName"/> or the model's /// additional view data. The template is found using the <paramref name="templateName"/> or the model's
/// <see cref="ModelBinding.ModelMetadata"/>. /// <see cref="ModelBinding.ModelMetadata"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="templateName">The name of the template used to create the HTML markup.</param> /// <param name="templateName">The name of the template used to create the HTML markup.</param>
/// <param name="htmlFieldName"> /// <param name="htmlFieldName">
/// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for /// A <see cref="string"/> used to disambiguate the names of HTML elements that are created for
@ -485,10 +538,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// case-sensitive file systems. /// case-sensitive file systems.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, public static HtmlString EditorForModel(
string htmlFieldName, object additionalViewData) [NotNull] this IHtmlHelper htmlHelper,
string templateName,
string htmlFieldName,
object additionalViewData)
{ {
return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, return htmlHelper.Editor(
expression: null,
templateName: templateName,
htmlFieldName: htmlFieldName,
additionalViewData: additionalViewData); additionalViewData: additionalViewData);
} }
} }

View File

@ -12,64 +12,64 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static class HtmlHelperLabelExtensions public static class HtmlHelperLabelExtensions
{ {
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified expression <paramref name="name"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString Label([NotNull] this IHtmlHelper html, string expression) public static HtmlString Label([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return html.Label(expression, return htmlHelper.Label(expression, labelText: null, htmlAttributes: null);
labelText: null,
htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified expression <paramref name="name"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="labelText">The inner text of the element.</param> /// <param name="labelText">The inner text of the element.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString Label([NotNull] this IHtmlHelper html, string expression, string labelText) public static HtmlString Label([NotNull] this IHtmlHelper htmlHelper, string expression, string labelText)
{ {
return html.Label(expression, labelText, htmlAttributes: null); return htmlHelper.Label(expression, labelText, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString LabelFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return html.LabelFor<TValue>(expression, labelText: null, htmlAttributes: null); return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="labelText">The inner text of the element.</param> /// <param name="labelText">The inner text of the element.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString LabelFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
string labelText) [NotNull] Expression<Func<TModel, TResult>> expression,
string labelText)
{ {
return html.LabelFor<TValue>(expression, labelText, htmlAttributes: null); return htmlHelper.LabelFor<TResult>(expression, labelText, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
@ -77,55 +77,56 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// attributes. /// attributes.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelFor<TModel, TValue>([NotNull] this IHtmlHelper<TModel> html, public static HtmlString LabelFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TValue>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
object htmlAttributes) [NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes)
{ {
return html.LabelFor<TValue>(expression, labelText: null, htmlAttributes: htmlAttributes); return htmlHelper.LabelFor<TResult>(expression, labelText: null, htmlAttributes: htmlAttributes);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the current model. /// Returns a &lt;label&gt; element for the current model.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelForModel([NotNull] this IHtmlHelper html) public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return html.Label(expression: null, labelText: null, htmlAttributes: null); return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the current model. /// Returns a &lt;label&gt; element for the current model.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="labelText">The inner text of the element.</param> /// <param name="labelText">The inner text of the element.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText) public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper, string labelText)
{ {
return html.Label(expression: null, labelText: labelText, htmlAttributes: null); return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the current model. /// Returns a &lt;label&gt; element for the current model.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing the HTML /// <see cref="System.Collections.Generic.IDictionary{string, object}"/> instance containing the HTML
/// attributes. /// attributes.
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, object htmlAttributes) public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper, object htmlAttributes)
{ {
return html.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes); return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes);
} }
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the current model. /// Returns a &lt;label&gt; element for the current model.
/// </summary> /// </summary>
/// <param name="html">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="labelText">The inner text of the element.</param> /// <param name="labelText">The inner text of the element.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
@ -134,11 +135,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
public static HtmlString LabelForModel( public static HtmlString LabelForModel(
[NotNull] this IHtmlHelper html, [NotNull] this IHtmlHelper htmlHelper,
string labelText, string labelText,
object htmlAttributes) object htmlAttributes)
{ {
return html.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes); return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes);
} }
} }
} }

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A <see cref="string"/> containing the element name.</returns> /// <returns>A <see cref="string"/> containing the element name.</returns>
public static string NameForModel([NotNull] this IHtmlHelper htmlHelper) public static string NameForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return htmlHelper.Name(name: null); return htmlHelper.Name(expression: null);
} }
/// <summary> /// <summary>
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A <see cref="string"/> containing the element Id.</returns> /// <returns>A <see cref="string"/> containing the element Id.</returns>
public static string IdForModel([NotNull] this IHtmlHelper htmlHelper) public static string IdForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return htmlHelper.Id(name: null); return htmlHelper.Id(expression: null);
} }
} }
} }

View File

@ -13,71 +13,78 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static class HtmlHelperSelectExtensions public static class HtmlHelperSelectExtensions
{ {
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>. /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name) public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return htmlHelper.DropDownList(name, selectList: null, optionLabel: null, htmlAttributes: null); return htmlHelper.DropDownList(expression, selectList: null, optionLabel: null, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>, /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the
/// using the option label. /// option label.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="optionLabel"> /// <param name="optionLabel">
/// The text for a default empty item. Does not include such an item if argument is <c>null</c>. /// The text for a default empty item. Does not include such an item if argument is <c>null</c>.
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, string optionLabel) public static HtmlString DropDownList(
[NotNull] this IHtmlHelper htmlHelper,
string expression,
string optionLabel)
{ {
return htmlHelper.DropDownList(name, selectList: null, optionLabel: optionLabel, htmlAttributes: null); return htmlHelper.DropDownList(
expression,
selectList: null,
optionLabel: optionLabel,
htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>, /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the
/// using the specified list items. /// specified list items.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownList( public static HtmlString DropDownList(
[NotNull] this IHtmlHelper htmlHelper, [NotNull] this IHtmlHelper htmlHelper,
string name, string expression,
IEnumerable<SelectListItem> selectList) IEnumerable<SelectListItem> selectList)
{ {
return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: null); return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>, /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the
/// using the specified list items and HTML attributes. /// specified list items and HTML attributes.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
@ -88,25 +95,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownList( public static HtmlString DropDownList(
[NotNull] this IHtmlHelper htmlHelper, [NotNull] this IHtmlHelper htmlHelper,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
object htmlAttributes) object htmlAttributes)
{ {
return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: htmlAttributes); return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: htmlAttributes);
} }
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>, /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the
/// using the specified list items and option label. /// specified list items and option label.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
@ -116,17 +123,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownList( public static HtmlString DropDownList(
[NotNull] this IHtmlHelper htmlHelper, [NotNull] this IHtmlHelper htmlHelper,
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
string optionLabel) string optionLabel)
{ {
return htmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes: null); return htmlHelper.DropDownList(expression, selectList, optionLabel, htmlAttributes: null);
} }
/// <summary> /// <summary>
@ -140,15 +147,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownListFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString DropDownListFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList)
{ {
return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, htmlAttributes: null); return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, htmlAttributes: null);
} }
@ -168,18 +177,23 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownListFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString DropDownListFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList,
object htmlAttributes) object htmlAttributes)
{ {
return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, return htmlHelper.DropDownListFor(
expression,
selectList,
optionLabel: null,
htmlAttributes: htmlAttributes); htmlAttributes: htmlAttributes);
} }
@ -197,58 +211,60 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The text for a default empty item. Does not include such an item if argument is <c>null</c>. /// The text for a default empty item. Does not include such an item if argument is <c>null</c>.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
public static HtmlString DropDownListFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString DropDownListFor<TModel, TResult>([
[NotNull] Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList,
string optionLabel) string optionLabel)
{ {
return htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes: null); return htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a multi-selection &lt;select&gt; element for the expression <paramref name="name"/>. /// Returns a multi-selection &lt;select&gt; element for the <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString ListBox([NotNull] this IHtmlHelper htmlHelper, string name) public static HtmlString ListBox([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return htmlHelper.ListBox(name, selectList: null, htmlAttributes: null); return htmlHelper.ListBox(expression, selectList: null, htmlAttributes: null);
} }
/// <summary> /// <summary>
/// Returns a multi-selection &lt;select&gt; element for the expression <paramref name="name"/>, using the /// Returns a multi-selection &lt;select&gt; element for the <paramref name="expression"/>, using the
/// specified list items. /// specified list items.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
public static HtmlString ListBox( public static HtmlString ListBox(
[NotNull] this IHtmlHelper htmlHelper, [NotNull] this IHtmlHelper htmlHelper,
string name, string expression,
IEnumerable<SelectListItem> selectList) IEnumerable<SelectListItem> selectList)
{ {
return htmlHelper.ListBox(name, selectList, htmlAttributes: null); return htmlHelper.ListBox(expression, selectList, htmlAttributes: null);
} }
/// <summary> /// <summary>
@ -262,16 +278,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
public static HtmlString ListBoxFor<TModel, TProperty>( public static HtmlString ListBoxFor<TModel, TResult>(
[NotNull] this IHtmlHelper<TModel> htmlHelper, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList) IEnumerable<SelectListItem> selectList)
{ {
return htmlHelper.ListBoxFor(expression, selectList, htmlAttributes: null); return htmlHelper.ListBoxFor(expression, selectList, htmlAttributes: null);

View File

@ -13,20 +13,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/> /// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/>
/// object for the specified expression <paramref name="expression"/>. /// object for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
/// <remarks> /// <remarks>
/// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message /// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message
/// will always be visible but client-side validation may update the associated CSS class. /// will always be visible but client-side validation may update the associated CSS class.
/// </remarks> /// </remarks>
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationMessage(
[NotNull] this IHtmlHelper htmlHelper,
string expression) string expression)
{ {
return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null); return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null);
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/> /// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/>
/// object for the specified expression <paramref name="expression"/>. /// object for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
@ -45,10 +45,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationMessage(
[NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string message) string message)
{ {
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/> /// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/>
/// object for the specified expression <paramref name="expression"/>. /// object for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
@ -69,14 +69,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
/// <remarks> /// <remarks>
/// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message /// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message
/// will always be visible but client-side validation may update the associated CSS class. /// will always be visible but client-side validation may update the associated CSS class.
/// </remarks> /// </remarks>
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationMessage(
[NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
object htmlAttributes) object htmlAttributes)
{ {
@ -85,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/> /// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/>
/// object for the specified expression <paramref name="expression"/>. /// object for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
@ -100,9 +100,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <paramref name="tag"/> element. <c>null</c> if the /// A new <see cref="HtmlString"/> containing a <paramref name="tag"/> element. <c>null</c> if the
/// expression <paramref name="expression"/> is valid and client-side validation is disabled. /// <paramref name="expression"/> is valid and client-side validation is disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationMessage(
[NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string message, string message,
string tag) string tag)
@ -112,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/> /// Returns the validation message if an error exists in the <see cref="ModelBinding.ModelStateDictionary"/>
/// object for the specified expression <paramref name="expression"/>. /// object for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
@ -129,10 +130,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationMessage(
[NotNull] this IHtmlHelper htmlHelper,
string expression, string expression,
string message, string message,
object htmlAttributes) object htmlAttributes)
@ -147,18 +148,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
/// <remarks> /// <remarks>
/// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message /// Method extracts an error string from the <see cref="ModelBinding.ModelStateDictionary"/> object. Message
/// will always be visible but client-side validation may update the associated CSS class. /// will always be visible but client-side validation may update the associated CSS class.
/// </remarks> /// </remarks>
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString ValidationMessageFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null); return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null);
} }
@ -175,14 +176,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// validation may update the associated CSS class. /// validation may update the associated CSS class.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString ValidationMessageFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string message) string message)
{ {
return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null); return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null);
@ -206,14 +207,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// attributes. /// attributes.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element. /// A new <see cref="HtmlString"/> containing a <see cref="ViewContext.ValidationMessageElement"/> element.
/// <c>null</c> if the expression <paramref name="expression"/> is valid and client-side validation is /// <c>null</c> if the <paramref name="expression"/> is valid and client-side validation is disabled.
/// disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString ValidationMessageFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string message, string message,
object htmlAttributes) object htmlAttributes)
{ {
@ -236,13 +237,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <see cref="ViewContext.ValidationMessageElement"/>. /// <see cref="ViewContext.ValidationMessageElement"/>.
/// </param> /// </param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing the <paramref name="tag"/> element. <c>null</c> if the /// A new <see cref="HtmlString"/> containing the <paramref name="tag"/> element. <c>null</c> if the
/// <paramref name="expression"/> is valid and client-side validation is disabled. /// <paramref name="expression"/> is valid and client-side validation is disabled.
/// </returns> /// </returns>
public static HtmlString ValidationMessageFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString ValidationMessageFor<TModel, TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TResult>> expression,
string message, string message,
string tag) string tag)
{ {
@ -260,7 +262,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper) public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors: false, return htmlHelper.ValidationSummary(
excludePropertyErrors: false,
message: null, message: null,
htmlAttributes: null, htmlAttributes: null,
tag: null); tag: null);
@ -280,7 +283,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors) public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors, return htmlHelper.ValidationSummary(
excludePropertyErrors,
message: null, message: null,
htmlAttributes: null, htmlAttributes: null,
tag: null); tag: null);
@ -300,7 +304,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message) public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors: false, return htmlHelper.ValidationSummary(
excludePropertyErrors: false,
message: message, message: message,
htmlAttributes: null, htmlAttributes: null,
tag: null); tag: null);
@ -323,7 +328,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message, string tag) public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message, string tag)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors: false, return htmlHelper.ValidationSummary(
excludePropertyErrors: false,
message: message, message: message,
htmlAttributes: null, htmlAttributes: null,
tag: tag); tag: tag);
@ -344,11 +350,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model /// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model
/// is valid and client-side validation is disabled). /// is valid and client-side validation is disabled).
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationSummary(
[NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors, bool excludePropertyErrors,
string message) string message)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors, return htmlHelper.ValidationSummary(
excludePropertyErrors,
message, message,
htmlAttributes: null, htmlAttributes: null,
tag: null); tag: null);
@ -371,12 +379,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model /// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model
/// is valid and client-side validation is disabled). /// is valid and client-side validation is disabled).
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationSummary(
[NotNull] this IHtmlHelper htmlHelper,
string message, string message,
object htmlAttributes) object htmlAttributes)
{ {
return htmlHelper.ValidationSummary( return htmlHelper.ValidationSummary(
excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes, tag: null); excludePropertyErrors: false,
message: message,
htmlAttributes: htmlAttributes,
tag: null);
} }
/// <summary> /// <summary>
@ -399,13 +411,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side /// and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side
/// validation is disabled). /// validation is disabled).
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationSummary(
[NotNull] this IHtmlHelper htmlHelper,
string message, string message,
object htmlAttributes, object htmlAttributes,
string tag) string tag)
{ {
return htmlHelper.ValidationSummary( return htmlHelper.ValidationSummary(
excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes, tag: tag); excludePropertyErrors: false,
message: message,
htmlAttributes: htmlAttributes,
tag: tag);
} }
/// <summary> /// <summary>
@ -426,12 +442,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side /// and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model is valid and client-side
/// validation is disabled). /// validation is disabled).
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationSummary(
[NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors, bool excludePropertyErrors,
string message, string message,
string tag) string tag)
{ {
return htmlHelper.ValidationSummary(excludePropertyErrors, return htmlHelper.ValidationSummary(
excludePropertyErrors,
message, message,
htmlAttributes: null, htmlAttributes: null,
tag: tag); tag: tag);
@ -457,7 +475,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model /// <paramref name="message"/>) and the &lt;ul&gt; element. <see cref="HtmlString.Empty"/> if the current model
/// is valid and client-side validation is disabled). /// is valid and client-side validation is disabled).
/// </returns> /// </returns>
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, public static HtmlString ValidationSummary(
[NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors, bool excludePropertyErrors,
string message, string message,
object htmlAttributes) object htmlAttributes)

View File

@ -12,17 +12,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static class HtmlHelperValueExtensions public static class HtmlHelperValueExtensions
{ {
/// <summary> /// <summary>
/// Returns the formatted value for the specified expression <paramref name="name"/>. /// Returns the formatted value for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A <see cref="string"/> containing the formatted value.</returns> /// <returns>A <see cref="string"/> containing the formatted value.</returns>
/// <remarks> /// <remarks>
/// Converts the expression result to a <see cref="string"/> directly. /// Converts the expression result to a <see cref="string"/> directly.
/// </remarks> /// </remarks>
public static string Value([NotNull] this IHtmlHelper htmlHelper, string name) public static string Value([NotNull] this IHtmlHelper htmlHelper, string expression)
{ {
return htmlHelper.Value(name, format: null); return htmlHelper.Value(expression, format: null);
} }
/// <summary> /// <summary>
@ -31,14 +31,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param> /// <param name="htmlHelper">The <see cref="IHtmlHelper{TModel}"/> instance this method extends.</param>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TModel">The type of the model.</typeparam> /// <typeparam name="TModel">The type of the model.</typeparam>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the formatted value.</returns> /// <returns>A <see cref="string"/> containing the formatted value.</returns>
/// <remarks> /// <remarks>
/// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly. /// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly.
/// </remarks> /// </remarks>
public static string ValueFor<TModel, TProperty>( public static string ValueFor<TModel, TResult>(
[NotNull] this IHtmlHelper<TModel> htmlHelper, [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression) [NotNull] Expression<Func<TModel, TResult>> expression)
{ {
return htmlHelper.ValueFor(expression, format: null); return htmlHelper.ValueFor(expression, format: null);
} }
@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </remarks> /// </remarks>
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper) public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper)
{ {
return htmlHelper.Value(name: null, format: null); return htmlHelper.Value(expression: null, format: null);
} }
/// <summary> /// <summary>
@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </remarks> /// </remarks>
public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format) public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format)
{ {
return htmlHelper.Value(name: null, format: format); return htmlHelper.Value(expression: null, format: format);
} }
} }
} }

View File

@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns an &lt;input&gt; element of type "checkbox" with value "true" and an &lt;input&gt; element of type /// Returns an &lt;input&gt; element of type "checkbox" with value "true" and an &lt;input&gt; element of type
/// "hidden" with value "false". /// "hidden" with value "false".
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="isChecked">If <c>true</c>, checkbox is initially checked.</param> /// <param name="isChecked">If <c>true</c>, checkbox is initially checked.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the checkbox element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the checkbox element. Alternatively, an
@ -152,23 +152,24 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; elements.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; elements.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set checkbox /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set checkbox
/// element's "name" attribute. Sanitizes <paramref name="name"/> to set checkbox element's "id" attribute. /// element's "name" attribute. Sanitizes <paramref name="expression"/> to set checkbox element's "id"
/// attribute.
/// </para> /// </para>
/// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para> /// <para>Determines checkbox element's "checked" attribute based on the following precedence:</para>
/// <list type="number"> /// <list type="number">
/// <item> /// <item>
/// <see cref="ModelStateDictionary"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ModelStateDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
/// if entry exists and can be converted to a <see cref="bool"/>. /// name) if entry exists and can be converted to a <see cref="bool"/>.
/// </item> /// </item>
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item> /// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
/// <item> /// <item>
/// <see cref="ViewData"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ViewData"/> entry for <paramref name="expression"/> (converted to a fully-qualified name)
/// if entry exists and can be converted to a <see cref="bool"/>. /// if entry exists and can be converted to a <see cref="bool"/>.
/// </item> /// </item>
/// <item> /// <item>
/// Linq expression based on <paramref name="name"/> (converted to a fully-qualified name) run against current /// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
/// model if result is non-<c>null</c> and can be converted to a <see cref="bool"/>. For example /// current model if result is non-<c>null</c> and can be converted to a <see cref="bool"/>. For example
/// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop"
/// property. /// property.
/// </item> /// </item>
@ -180,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// value "checked" if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise. /// value "checked" if the <see cref="bool"/> values is <c>true</c>; does not include the attribute otherwise.
/// </para> /// </para>
/// </remarks> /// </remarks>
HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes); HtmlString CheckBox(string expression, bool? isChecked, object htmlAttributes);
/// <summary> /// <summary>
/// Returns HTML markup for the <paramref name="expression"/>, using a display template, specified HTML field /// Returns HTML markup for the <paramref name="expression"/>, using a display template, specified HTML field
@ -219,27 +220,27 @@ namespace Microsoft.AspNet.Mvc.Rendering
object additionalViewData); object additionalViewData);
/// <summary> /// <summary>
/// Returns the display name for the specified expression <paramref name="expression"/>. /// Returns the display name for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A <see cref="string"/> containing the display name.</returns> /// <returns>A <see cref="string"/> containing the display name.</returns>
string DisplayName(string expression); string DisplayName(string expression);
/// <summary> /// <summary>
/// Returns the simple display text for the specified expression <paramref name="name"/>. /// Returns the simple display text for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns> /// <returns>
/// A <see cref="string"/> containing the simple display text. /// A <see cref="string"/> containing the simple display text.
/// If the expression result is <c>null</c>, returns <see cref="ModelMetadata.NullDisplayText"/>. /// If the expression result is <c>null</c>, returns <see cref="ModelMetadata.NullDisplayText"/>.
/// </returns> /// </returns>
string DisplayText(string name); string DisplayText(string expression);
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the expression <paramref name="name"/>, /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>,
/// using the specified list items, option label, and HTML attributes. /// using the specified list items, option label, and HTML attributes.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
@ -253,12 +254,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
HtmlString DropDownList( HtmlString DropDownList(
string name, string expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
string optionLabel, string optionLabel,
object htmlAttributes); object htmlAttributes);
@ -332,30 +333,30 @@ namespace Microsoft.AspNet.Mvc.Rendering
string FormatValue(object value, string format); string FormatValue(object value, string format);
/// <summary> /// <summary>
/// Returns an HTML element Id for the specified expression <paramref name="name"/>. /// Returns an HTML element Id for the specified expression <paramref name="fullName"/>.
/// </summary> /// </summary>
/// <param name="name"> /// <param name="fullName">
/// Fully-qualified expression name, ignoring the current model. Must not be <c>null</c>. /// Fully-qualified expression name, ignoring the current model. Must not be <c>null</c>.
/// </param> /// </param>
/// <returns>A <see cref="string"/> containing the element Id.</returns> /// <returns>A <see cref="string"/> containing the element Id.</returns>
string GenerateIdFromName([NotNull] string name); string GenerateIdFromName([NotNull] string fullName);
/// <summary> /// <summary>
/// Returns information about about client validation rules for the specified <paramref name="metadata"/> or /// Returns information about about client validation rules for the specified <paramref name="metadata"/> or
/// <paramref name="name"/>. Intended for use in <see cref="IHtmlHelper"/> extension methods. /// <paramref name="expression"/>. Intended for use in <see cref="IHtmlHelper"/> extension methods.
/// </summary> /// </summary>
/// <param name="metadata">Metadata about the <see cref="object"/> of interest.</param> /// <param name="metadata">Metadata about the <see cref="object"/> of interest.</param>
/// <param name="name"> /// <param name="expression">
/// Expression name, relative to the current model. Used to determine <see cref="ModelMetadata"/> when /// Expression name, relative to the current model. Used to determine <see cref="ModelMetadata"/> when
/// <paramref name="metadata"/> is <c>null</c>; ignored otherwise. /// <paramref name="metadata"/> is <c>null</c>; ignored otherwise.
/// </param> /// </param>
/// <returns>An <see cref="IEnumerable{ModelClientValidationRule}"/> containing the relevant rules.</returns> /// <returns>An <see cref="IEnumerable{ModelClientValidationRule}"/> containing the relevant rules.</returns>
IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, string name); IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, string expression);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "hidden" for the specified expression <paramref name="name"/>. /// Returns an &lt;input&gt; element of type "hidden" for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</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="value">If non-<c>null</c>, value to include in the element.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
@ -364,24 +365,24 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </para> /// </para>
/// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para> /// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para>
/// <list type="number"> /// <list type="number">
/// <item> /// <item>
/// <see cref="ModelStateDictionary"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ModelStateDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
/// if entry exists and can be converted to a <see cref="string"/>. /// name) if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item><paramref name="value"/> if non-<c>null</c>.</item> /// <item><paramref name="value"/> if non-<c>null</c>.</item>
/// <item> /// <item>
/// <see cref="ViewData"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ViewData"/> entry for <paramref name="expression"/> (converted to a fully-qualified name)
/// if entry exists and can be converted to a <see cref="string"/>. /// if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item> /// <item>
/// Linq expression based on <paramref name="name"/> (converted to a fully-qualified name) run against current /// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
/// model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example /// current model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example
/// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop"
/// property. /// property.
/// </item> /// </item>
@ -389,17 +390,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString Hidden(string name, object value, object htmlAttributes); HtmlString Hidden(string expression, object value, object htmlAttributes);
/// <summary> /// <summary>
/// Returns the HTML element Id for the specified expression <paramref name="name"/>. /// Returns the HTML element Id for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A <see cref="string"/> containing the element Id.</returns> /// <returns>A <see cref="string"/> containing the element Id.</returns>
string Id(string name); string Id(string expression);
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified expression <paramref name="name"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="labelText">The inner text of the element.</param> /// <param name="labelText">The inner text of the element.</param>
@ -411,10 +412,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
HtmlString Label(string expression, string labelText, object htmlAttributes); HtmlString Label(string expression, string labelText, object htmlAttributes);
/// <summary> /// <summary>
/// Returns a multi-selection &lt;select&gt; element for the expression <paramref name="name"/>, using the /// Returns a multi-selection &lt;select&gt; element for the <paramref name="expression"/>, using the
/// specified list items and HTML attributes. /// specified list items and HTML attributes.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="selectList"> /// <param name="selectList">
/// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with /// A collection of <see cref="SelectListItem"/> objects used to populate the &lt;select&gt; element with
/// &lt;optgroup&gt; and &lt;option&gt; elements. /// &lt;optgroup&gt; and &lt;option&gt; elements.
@ -425,18 +426,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;select&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </remarks> /// </remarks>
HtmlString ListBox(string name, IEnumerable<SelectListItem> selectList, object htmlAttributes); HtmlString ListBox(string expression, IEnumerable<SelectListItem> selectList, object htmlAttributes);
/// <summary> /// <summary>
/// Returns the full HTML element name for the specified expression <paramref name="name"/>. /// Returns the full HTML element name for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <returns>A <see cref="string"/> containing the element name.</returns> /// <returns>A <see cref="string"/> containing the element name.</returns>
string Name(string name); string Name(string expression);
/// <summary> /// <summary>
/// Returns HTML markup for the specified partial view. /// Returns HTML markup for the specified partial view.
@ -453,9 +454,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
Task<HtmlString> PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); Task<HtmlString> PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "password" for the specified expression <paramref name="name"/>. /// Returns an &lt;input&gt; element of type "password" for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</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="value">If non-<c>null</c>, value to include in the element.</param>
/// <param name="htmlAttributes"> /// <param name="htmlAttributes">
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
@ -464,8 +465,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </para> /// </para>
/// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para> /// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para>
@ -475,12 +476,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString Password(string name, object value, object htmlAttributes); HtmlString Password(string expression, object value, object htmlAttributes);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "radio" for the specified expression <paramref name="name"/>. /// Returns an &lt;input&gt; element of type "radio" for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="value"> /// <param name="value">
/// If non-<c>null</c>, value to include in the element. Must not be <c>null</c> if /// If non-<c>null</c>, value to include in the element. Must not be <c>null</c> if
/// <paramref name="isChecked"/> is also <c>null</c> and no "checked" entry exists in /// <paramref name="isChecked"/> is also <c>null</c> and no "checked" entry exists in
@ -498,8 +499,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </para> /// </para>
/// <para>Determines element's "value" attribute based on the following precedence:</para> /// <para>Determines element's "value" attribute based on the following precedence:</para>
@ -511,18 +512,18 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <para>Determines &lt;input&gt; element's "checked" attribute based on the following precedence:</para> /// <para>Determines &lt;input&gt; element's "checked" attribute based on the following precedence:</para>
/// <list type="number"> /// <list type="number">
/// <item> /// <item>
/// <see cref="ModelStateDictionary"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ModelStateDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
/// if entry exists and can be converted to a <see cref="string"/>. /// name) if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item><paramref name="isChecked"/> if non-<c>null</c>.</item> /// <item><paramref name="isChecked"/> if non-<c>null</c>.</item>
/// <item>Existing "checked" entry in <paramref name="htmlAttributes"/> if any.</item> /// <item>Existing "checked" entry in <paramref name="htmlAttributes"/> if any.</item>
/// <item> /// <item>
/// <see cref="ViewData"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ViewData"/> entry for <paramref name="expression"/> (converted to a fully-qualified name)
/// if entry exists and can be converted to a <see cref="string"/>. /// if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item> /// <item>
/// Linq expression based on <paramref name="name"/> (converted to a fully-qualified name) run against current /// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
/// model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example /// current model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example
/// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop"
/// property. /// property.
/// </item> /// </item>
@ -535,7 +536,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// the attribute otherwise. /// the attribute otherwise.
/// </para> /// </para>
/// </remarks> /// </remarks>
HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes); HtmlString RadioButton(string expression, object value, bool? isChecked, object htmlAttributes);
/// <summary> /// <summary>
/// Wraps HTML markup in an <see cref="HtmlString"/>, without HTML-encoding the specified /// Wraps HTML markup in an <see cref="HtmlString"/>, without HTML-encoding the specified
@ -596,9 +597,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
object htmlAttributes); object htmlAttributes);
/// <summary> /// <summary>
/// Returns a &lt;textarea&gt; element for the specified expression <paramref name="name"/>. /// Returns a &lt;textarea&gt; element for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</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="value">If non-<c>null</c>, value to include in the element.</param>
/// <param name="rows">Number of rows in the textarea.</param> /// <param name="rows">Number of rows in the textarea.</param>
/// <param name="columns">Number of columns in the textarea.</param> /// <param name="columns">Number of columns in the textarea.</param>
@ -609,36 +610,36 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;textarea&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;textarea&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="expression"/> to set
/// &lt;textarea&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;textarea&gt; element's "name" attribute. Sanitizes <paramref name="expression"/> to set element's "id"
/// attribute. /// attribute.
/// </para> /// </para>
/// <para>Determines &lt;textarea&gt; element's content based on the following precedence:</para> /// <para>Determines &lt;textarea&gt; element's content based on the following precedence:</para>
/// <list type="number"> /// <list type="number">
/// <item> /// <item>
/// <see cref="ModelStateDictionary"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ModelStateDictionary"/> entry for <paramref name="expression"/> (converted to a fully-qualified
/// if entry exists and can be converted to a <see cref="string"/>. /// name) if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item><paramref name="value"/> if non-<c>null</c>.</item> /// <item><paramref name="value"/> if non-<c>null</c>.</item>
/// <item> /// <item>
/// <see cref="ViewData"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ViewData"/> entry for <paramref name="expression"/> (converted to a fully-qualified name)
/// if entry exists and can be converted to a <see cref="string"/>. /// if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item> /// <item>
/// Linq expression based on <paramref name="name"/> (converted to a fully-qualified name) run against current /// Linq expression based on <paramref name="expression"/> (converted to a fully-qualified name) run against
/// model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example /// current model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example
/// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop"
/// property. /// property.
/// </item> /// </item>
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString TextArea(string name, string value, int rows, int columns, object htmlAttributes); HtmlString TextArea(string expression, string value, int rows, int columns, object htmlAttributes);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "text" for the specified expression <paramref name="name"/>. /// Returns an &lt;input&gt; element of type "text" for the specified <paramref name="current"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="current">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="value">If non-<c>null</c>, value to include in the element.</param>
/// <param name="format"> /// <param name="format">
/// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
@ -650,15 +651,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="name"/> to set /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and <paramref name="current"/> to set
/// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="name"/> to set element's "id" /// &lt;input&gt; element's "name" attribute. Sanitizes <paramref name="current"/> to set element's "id"
/// attribute. /// attribute.
/// </para> /// </para>
/// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para> /// <para>Determines &lt;input&gt; element's "value" attribute based on the following precedence:</para>
/// <list type="number"> /// <list type="number">
/// <item> /// <item>
/// <see cref="ModelStateDictionary"/> entry for <paramref name="name"/> (converted to a fully-qualified name) /// <see cref="ModelStateDictionary"/> entry for <paramref name="current"/> (converted to a fully-qualified
/// if entry exists and can be converted to a <see cref="string"/>. /// name) if entry exists and can be converted to a <see cref="string"/>.
/// </item> /// </item>
/// <item> /// <item>
/// <paramref name="value"/> if non-<c>null</c>. Formats <paramref name="value"/> using /// <paramref name="value"/> if non-<c>null</c>. Formats <paramref name="value"/> using
@ -666,13 +667,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <paramref name="format"/> is <c>null</c> or empty. /// <paramref name="format"/> is <c>null</c> or empty.
/// </item> /// </item>
/// <item> /// <item>
/// <see cref="ViewData"/> entry for <paramref name="name"/> (converted to a fully-qualified name) if entry /// <see cref="ViewData"/> entry for <paramref name="current"/> (converted to a fully-qualified name) if entry
/// exists and can be converted to a <see cref="string"/>. Formats entry using <paramref name="format"/> or /// exists and can be converted to a <see cref="string"/>. Formats entry using <paramref name="format"/> or
/// converts entry to a <see cref="string"/> directly if <paramref name="format"/> is <c>null</c> or empty. /// converts entry to a <see cref="string"/> directly if <paramref name="format"/> is <c>null</c> or empty.
/// </item> /// </item>
/// <item> /// <item>
/// Linq expression based on <paramref name="name"/> (converted to a fully-qualified name) run against current /// Linq expression based on <paramref name="current"/> (converted to a fully-qualified name) run against
/// model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example /// current model if result is non-<c>null</c> and can be converted to a <see cref="string"/>. For example
/// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop" /// <c>string.Empty</c> identifies the current model and <c>"prop"</c> identifies the current model's "prop"
/// property. Formats result using <paramref name="format"/> or converts result to a <see cref="string"/> /// property. Formats result using <paramref name="format"/> or converts result to a <see cref="string"/>
/// directly if <paramref name="format"/> is <c>null</c> or empty. /// directly if <paramref name="format"/> is <c>null</c> or empty.
@ -681,13 +682,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString TextBox(string name, object value, string format, object htmlAttributes); HtmlString TextBox(string current, object value, string format, object htmlAttributes);
/// <summary> /// <summary>
/// Returns the validation message if an error exists in the <see cref="ModelStateDictionary"/> object /// Returns the validation message if an error exists in the <see cref="ModelStateDictionary"/> object
/// for the specified expression <paramref name="modelName"/>. /// for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="modelName">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="message"> /// <param name="message">
/// The message to be displayed. If <c>null</c> or empty, method extracts an error string from the /// The message to be displayed. If <c>null</c> or empty, method extracts an error string from the
/// <see cref="ModelStateDictionary"/> object. Message will always be visible but client-side validation may /// <see cref="ModelStateDictionary"/> object. Message will always be visible but client-side validation may
@ -703,9 +704,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </param> /// </param>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing a <paramref name="tag"/> element. <c>null</c> if the /// A new <see cref="HtmlString"/> containing a <paramref name="tag"/> element. <c>null</c> if the
/// expression <paramref name="modelName"/> is valid and client-side validation is disabled. /// <paramref name="expression"/> is valid and client-side validation is disabled.
/// </returns> /// </returns>
HtmlString ValidationMessage(string modelName, string message, object htmlAttributes, string tag); HtmlString ValidationMessage(string expression, string message, object htmlAttributes, string tag);
/// <summary> /// <summary>
/// Returns an unordered list (&lt;ul&gt; element) of validation messages that are in the /// Returns an unordered list (&lt;ul&gt; element) of validation messages that are in the
@ -735,9 +736,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
string tag); string tag);
/// <summary> /// <summary>
/// Returns the formatted value for the specified expression <paramref name="name"/>. /// Returns the formatted value for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="name">Expression name, relative to the current model.</param> /// <param name="expression">Expression name, relative to the current model.</param>
/// <param name="format"> /// <param name="format">
/// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
/// </param> /// </param>
@ -746,6 +747,6 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Converts the expression result to a <see cref="string"/> directly if /// Converts the expression result to a <see cref="string"/> directly if
/// <paramref name="format"/> is <c>null</c> or empty. /// <paramref name="format"/> is <c>null</c> or empty.
/// </remarks> /// </remarks>
string Value(string name, string format); string Value(string expression, string format);
} }
} }

View File

@ -70,24 +70,25 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> instance created for the /// view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> instance created for the
/// template. /// template.
/// </param> /// </param>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns> /// <returns>A new <see cref="HtmlString"/> containing the created HTML.</returns>
/// <remarks> /// <remarks>
/// For example the default <see cref="object"/> display template includes markup for each property in the /// For example the default <see cref="object"/> display template includes markup for each property in the
/// <paramref name="expression"/> result. /// <paramref name="expression"/> result.
/// </remarks> /// </remarks>
HtmlString DisplayFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression, HtmlString DisplayFor<TResult>(
string templateName, [NotNull] Expression<Func<TModel, TResult>> expression,
string htmlFieldName, string templateName,
object additionalViewData); string htmlFieldName,
object additionalViewData);
/// <summary> /// <summary>
/// Returns the display name for the specified <paramref name="expression"/>. /// Returns the display name for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the display name.</returns> /// <returns>A <see cref="string"/> containing the display name.</returns>
string DisplayNameFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression); string DisplayNameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
/// <summary> /// <summary>
/// Returns the display name for the specified <paramref name="expression"/> /// Returns the display name for the specified <paramref name="expression"/>
@ -95,22 +96,22 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// </summary> /// </summary>
/// <param name="expression">An expression to be evaluated against an item in the current model.</param> /// <param name="expression">An expression to be evaluated against an item in the current model.</param>
/// <typeparam name="TModelItem">The type of items in the model collection.</typeparam> /// <typeparam name="TModelItem">The type of items in the model collection.</typeparam>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the display name.</returns> /// <returns>A <see cref="string"/> containing the display name.</returns>
string DisplayNameForInnerType<TModelItem, TValue>( string DisplayNameForInnerType<TModelItem, TResult>(
[NotNull] Expression<Func<TModelItem, TValue>> expression); [NotNull] Expression<Func<TModelItem, TResult>> expression);
/// <summary> /// <summary>
/// Returns the simple display text for the specified <paramref name="expression"/>. /// Returns the simple display text for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A <see cref="string"/> containing the simple display text. /// A <see cref="string"/> containing the simple display text.
/// If the <paramref name="expression"/> result is <c>null</c>, returns /// If the <paramref name="expression"/> result is <c>null</c>, returns
/// <see cref="ModelBinding.ModelMetadata.NullDisplayText"/>. /// <see cref="ModelBinding.ModelMetadata.NullDisplayText"/>.
/// </returns> /// </returns>
string DisplayTextFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression); string DisplayTextFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
/// <summary> /// <summary>
/// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the /// Returns a single-selection HTML &lt;select&gt; element for the <paramref name="expression"/>, using the
@ -128,15 +129,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
HtmlString DropDownListFor<TProperty>( HtmlString DropDownListFor<TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
string optionLabel, string optionLabel,
object htmlAttributes); object htmlAttributes);
@ -157,13 +158,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> instance created for the /// view data that will be merged into the <see cref="ViewDataDictionary{TModel}"/> instance created for the
/// template. /// template.
/// </param> /// </param>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element(s).</returns>
/// <remarks> /// <remarks>
/// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt; /// For example the default <see cref="object"/> editor template includes &lt;label&gt; and &lt;input&gt;
/// elements for each property in the <paramref name="expression"/> result. /// elements for each property in the <paramref name="expression"/> result.
/// </remarks> /// </remarks>
HtmlString EditorFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression, HtmlString EditorFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
string templateName, string templateName,
string htmlFieldName, string htmlFieldName,
object additionalViewData); object additionalViewData);
@ -176,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -198,16 +200,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString HiddenFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, HtmlString HiddenFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes); object htmlAttributes);
/// <summary> /// <summary>
/// Returns the HTML element Id for the specified <paramref name="expression"/>. /// Returns the HTML element Id for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the element Id.</returns> /// <returns>A <see cref="string"/> containing the element Id.</returns>
string IdFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression); string IdFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
/// <summary> /// <summary>
/// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>. /// Returns a &lt;label&gt; element for the specified <paramref name="expression"/>.
@ -218,11 +221,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TValue">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;label&gt; element.</returns>
HtmlString LabelFor<TValue>([NotNull] Expression<Func<TModel, TValue>> expression, HtmlString LabelFor<TResult>(
string labelText, [NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes); string labelText,
object htmlAttributes);
/// <summary> /// <summary>
/// Returns a multi-selection &lt;select&gt; element for the <paramref name="expression"/>, using the /// Returns a multi-selection &lt;select&gt; element for the <paramref name="expression"/>, using the
@ -237,15 +241,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;select&gt; element.</returns>
/// <remarks> /// <remarks>
/// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the /// Combines <see cref="TemplateInfo.HtmlFieldPrefix"/> and the string representation of the
/// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string /// <paramref name="expression"/> to set &lt;select&gt; element's "name" attribute. Sanitizes the string
/// representation of the <paramref name="expression"/> to set element's "id" attribute. /// representation of the <paramref name="expression"/> to set element's "id" attribute.
/// </remarks> /// </remarks>
HtmlString ListBoxFor<TProperty>( HtmlString ListBoxFor<TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
IEnumerable<SelectListItem> selectList, IEnumerable<SelectListItem> selectList,
object htmlAttributes); object htmlAttributes);
@ -253,9 +257,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Returns the full HTML element name for the specified <paramref name="expression"/>. /// Returns the full HTML element name for the specified <paramref name="expression"/>.
/// </summary> /// </summary>
/// <param name="expression">An expression to be evaluated against the current model.</param> /// <param name="expression">An expression to be evaluated against the current model.</param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the element name.</returns> /// <returns>A <see cref="string"/> containing the element name.</returns>
string NameFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression); string NameFor<TResult>([NotNull] Expression<Func<TModel, TResult>> expression);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "password" for the specified <paramref name="expression"/>. /// Returns an &lt;input&gt; element of type "password" for the specified <paramref name="expression"/>.
@ -265,7 +269,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -283,7 +287,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString PasswordFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, HtmlString PasswordFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
object htmlAttributes); object htmlAttributes);
/// <summary> /// <summary>
@ -295,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -322,8 +327,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <paramref name="value"/>; does not include the attribute otherwise. /// <paramref name="value"/>; does not include the attribute otherwise.
/// </para> /// </para>
/// </remarks> /// </remarks>
HtmlString RadioButtonFor<TProperty>( HtmlString RadioButtonFor<TResult>(
[NotNull] Expression<Func<TModel, TProperty>> expression, [NotNull] Expression<Func<TModel, TResult>> expression,
[NotNull] object value, [NotNull] object value,
object htmlAttributes); object htmlAttributes);
@ -337,7 +342,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;textarea&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;textarea&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -357,8 +362,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString TextAreaFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, HtmlString TextAreaFor<TResult>(
int rows, int columns, object htmlAttributes); [NotNull] Expression<Func<TModel, TResult>> expression,
int rows,
int columns,
object htmlAttributes);
/// <summary> /// <summary>
/// Returns an &lt;input&gt; element of type "text" for the specified <paramref name="expression"/>. /// Returns an &lt;input&gt; element of type "text" for the specified <paramref name="expression"/>.
@ -371,7 +379,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an /// An <see cref="object"/> that contains the HTML attributes for the element. Alternatively, an
/// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns> /// <returns>A new <see cref="HtmlString"/> containing the &lt;input&gt; element.</returns>
/// <remarks> /// <remarks>
/// <para> /// <para>
@ -394,7 +402,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <item>Otherwise, <c>string.Empty</c>.</item> /// <item>Otherwise, <c>string.Empty</c>.</item>
/// </list> /// </list>
/// </remarks> /// </remarks>
HtmlString TextBoxFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, string format, HtmlString TextBoxFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
string format,
object htmlAttributes); object htmlAttributes);
/// <summary> /// <summary>
@ -415,12 +425,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The tag to wrap the <paramref name="message"/> in the generated HTML. Its default value is /// The tag to wrap the <paramref name="message"/> in the generated HTML. Its default value is
/// <see cref="ViewContext.ValidationMessageElement"/>. /// <see cref="ViewContext.ValidationMessageElement"/>.
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns> /// <returns>
/// A new <see cref="HtmlString"/> containing the <paramref name="tag"/> element. <c>null</c> if the /// A new <see cref="HtmlString"/> containing the <paramref name="tag"/> element. <c>null</c> if the
/// <paramref name="expression"/> is valid and client-side validation is disabled. /// <paramref name="expression"/> is valid and client-side validation is disabled.
/// </returns> /// </returns>
HtmlString ValidationMessageFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, HtmlString ValidationMessageFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
string message, string message,
object htmlAttributes, object htmlAttributes,
string tag); string tag);
@ -432,12 +443,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <param name="format"> /// <param name="format">
/// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// The composite format <see cref="string"/> (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
/// </param> /// </param>
/// <typeparam name="TProperty">The type of the <paramref name="expression"/> result.</typeparam> /// <typeparam name="TResult">The type of the <paramref name="expression"/> result.</typeparam>
/// <returns>A <see cref="string"/> containing the formatted value.</returns> /// <returns>A <see cref="string"/> containing the formatted value.</returns>
/// <remarks> /// <remarks>
/// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly if /// Converts the <paramref name="expression"/> result to a <see cref="string"/> directly if
/// <paramref name="format"/> is <c>null</c> or empty. /// <paramref name="format"/> is <c>null</c> or empty.
/// </remarks> /// </remarks>
string ValueFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, string format); string ValueFor<TResult>(
[NotNull] Expression<Func<TModel, TResult>> expression,
string format);
} }
} }

View File

@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
ViewContext, ViewContext,
For.Metadata, For.Metadata,
optionLabel: null, optionLabel: null,
name: For.Name, expression: For.Name,
selectList: items, selectList: items,
allowMultiple: allowMultiple, allowMultiple: allowMultiple,
htmlAttributes: null, htmlAttributes: null,

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var helper = DefaultTemplatesUtilities.GetHtmlHelper<OverriddenToStringModel>(model: null); var helper = DefaultTemplatesUtilities.GetHtmlHelper<OverriddenToStringModel>(model: null);
// Act // Act
var result = helper.DisplayText(name: string.Empty); var result = helper.DisplayText(expression: string.Empty);
// Assert // Assert
Assert.Empty(result); Assert.Empty(result);
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
helper.ViewData.ModelMetadata.NullDisplayText = "Null display Text"; helper.ViewData.ModelMetadata.NullDisplayText = "Null display Text";
// Act // Act
var result = helper.DisplayText(name: string.Empty); var result = helper.DisplayText(expression: string.Empty);
// Assert // Assert
Assert.Equal("Null display Text", result); Assert.Equal("Null display Text", result);
@ -75,8 +75,8 @@ namespace Microsoft.AspNet.Mvc.Rendering
var helper = DefaultTemplatesUtilities.GetHtmlHelper(model); var helper = DefaultTemplatesUtilities.GetHtmlHelper(model);
// Act // Act
var result = helper.DisplayText(name: string.Empty); var result = helper.DisplayText(expression: string.Empty);
var nullResult = helper.DisplayText(name: null); // null is another alias for current model var nullResult = helper.DisplayText(expression: null); // null is another alias for current model
// Assert // Assert
Assert.Equal("Model value", result); Assert.Equal("Model value", result);
@ -120,7 +120,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
helper.ViewData.ModelMetadata.SimpleDisplayText = "Simple display text"; helper.ViewData.ModelMetadata.SimpleDisplayText = "Simple display text";
// Act // Act
var result = helper.DisplayText(name: string.Empty); var result = helper.DisplayText(expression: string.Empty);
// Assert // Assert
Assert.Equal("Simple display text", result); Assert.Equal("Simple display text", result);

View File

@ -290,7 +290,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Act and Assert // Act and Assert
ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Hidden(string.Empty, string.Empty, attributes), ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Hidden(string.Empty, string.Empty, attributes),
"name"); "expression");
} }
[Fact] [Fact]

View File

@ -21,12 +21,12 @@ namespace Microsoft.AspNet.Mvc.Core
var helper = DefaultTemplatesUtilities.GetHtmlHelper(); var helper = DefaultTemplatesUtilities.GetHtmlHelper();
// Act // Act
var idResult = helper.Id(name: string.Empty); var idResult = helper.Id(expression: string.Empty);
var idNullResult = helper.Id(name: null); // null is another alias for current model var idNullResult = helper.Id(expression: null); // null is another alias for current model
var idForResult = helper.IdFor(m => m); var idForResult = helper.IdFor(m => m);
var idForModelResult = helper.IdForModel(); var idForModelResult = helper.IdForModel();
var nameResult = helper.Name(name: string.Empty); var nameResult = helper.Name(expression: string.Empty);
var nameNullResult = helper.Name(name: null); var nameNullResult = helper.Name(expression: null);
var nameForResult = helper.NameFor(m => m); var nameForResult = helper.NameFor(m => m);
var nameForModelResult = helper.NameForModel(); var nameForModelResult = helper.NameForModel();
@ -54,10 +54,10 @@ namespace Microsoft.AspNet.Mvc.Core
helper.ViewData.TemplateInfo.HtmlFieldPrefix = prefix; helper.ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
// Act // Act
var idResult = helper.Id(name: string.Empty); var idResult = helper.Id(expression: string.Empty);
var idForResult = helper.IdFor(m => m); var idForResult = helper.IdFor(m => m);
var idForModelResult = helper.IdForModel(); var idForModelResult = helper.IdForModel();
var nameResult = helper.Name(name: string.Empty); var nameResult = helper.Name(expression: string.Empty);
var nameForResult = helper.NameFor(m => m); var nameForResult = helper.NameFor(m => m);
var nameForModelResult = helper.NameForModel(); var nameForModelResult = helper.NameForModel();
@ -149,10 +149,10 @@ namespace Microsoft.AspNet.Mvc.Core
var helper = DefaultTemplatesUtilities.GetHtmlHelper(provider.Object); var helper = DefaultTemplatesUtilities.GetHtmlHelper(provider.Object);
// Act (do not throw) // Act (do not throw)
var idResult = helper.Id(name: string.Empty); var idResult = helper.Id(expression: string.Empty);
var idForResult = helper.IdFor(m => m); var idForResult = helper.IdFor(m => m);
var idForModelResult = helper.IdForModel(); var idForModelResult = helper.IdForModel();
var nameResult = helper.Name(name: string.Empty); var nameResult = helper.Name(expression: string.Empty);
var nameForResult = helper.NameFor(m => m); var nameForResult = helper.NameFor(m => m);
var nameForModelResult = helper.NameForModel(); var nameForModelResult = helper.NameForModel();

View File

@ -130,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Act and Assert // Act and Assert
ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Password(name, value, htmlAttributes: null), ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Password(name, value, htmlAttributes: null),
"name"); "expression");
} }
[Fact] [Fact]

View File

@ -91,8 +91,8 @@ namespace Microsoft.AspNet.Mvc.Core
"{ StringProperty = ModelStringPropertyValue, ObjectProperty = 01/01/1900 00:00:00 }"; "{ StringProperty = ModelStringPropertyValue, ObjectProperty = 01/01/1900 00:00:00 }";
// Act & Assert // Act & Assert
Assert.Equal(expectedModelValue, helper.Value(name: string.Empty)); Assert.Equal(expectedModelValue, helper.Value(expression: string.Empty));
Assert.Equal(expectedModelValue, helper.Value(name: null)); // null is another alias for current model Assert.Equal(expectedModelValue, helper.Value(expression: null)); // null is another alias for current model
Assert.Equal(expectedModelValue, helper.ValueFor(m => m)); Assert.Equal(expectedModelValue, helper.ValueFor(m => m));
Assert.Equal(expectedModelValue, helper.ValueForModel()); Assert.Equal(expectedModelValue, helper.ValueForModel());
} }