Back `HtmlHelper.Html5DateRenderingMode` with new `ViewContext` property

- provides expected scoped semantics
- helps a bit with #448 but does not provide an app-wide default
This commit is contained in:
dougbu 2014-08-18 12:49:50 -07:00
parent dfcd5fe9a9
commit 0b548997d2
2 changed files with 20 additions and 1 deletions

View File

@ -59,7 +59,17 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
/// <inheritdoc />
public Html5DateRenderingMode Html5DateRenderingMode { get; set; }
public Html5DateRenderingMode Html5DateRenderingMode
{
get
{
return ViewContext.Html5DateRenderingMode;
}
set
{
ViewContext.Html5DateRenderingMode = value;
}
}
/// <inheritdoc />
public string IdAttributeDotReplacement { get; set; }

View File

@ -41,6 +41,7 @@ namespace Microsoft.AspNet.Mvc
{
_formContext = viewContext.FormContext;
ClientValidationEnabled = viewContext.ClientValidationEnabled;
Html5DateRenderingMode = viewContext.Html5DateRenderingMode;
ValidationSummaryMessageElement = viewContext.ValidationSummaryMessageElement;
ValidationMessageElement = viewContext.ValidationMessageElement;
@ -64,6 +65,14 @@ namespace Microsoft.AspNet.Mvc
public bool ClientValidationEnabled { get; set; }
/// <summary>
/// Set this property to <see cref="Html5DateRenderingMode.Rfc3339" /> to have templated helpers such as
/// <see cref="IHtmlHelper.Editor" /> and <see cref="IHtmlHelper{TModel}.EditorFor" /> render date and time
/// values as RFC 3339 compliant strings. By default these helpers render dates and times using the current
/// culture.
/// </summary>
public Html5DateRenderingMode Html5DateRenderingMode { get; set; }
/// <summary>
/// Element name used to wrap a top-level message generated by <see cref="IHtmlHelper.ValidationSummary"/> and
/// other overloads.