ViewContext Class¶
Context for view execution.
- Namespace
Microsoft.AspNetCore.Mvc.Rendering
- Assemblies
- Microsoft.AspNetCore.Mvc.ViewFeatures
Syntax¶
public class ViewContext : ActionContext
-
class
Microsoft.AspNetCore.Mvc.Rendering.
ViewContext
Constructors¶
-
ViewContext
()¶ Creates an empty
Microsoft.AspNetCore.Mvc.Rendering.ViewContext
.public ViewContext()
-
ViewContext
(Microsoft.AspNetCore.Mvc.ActionContext, Microsoft.AspNetCore.Mvc.ViewEngines.IView, Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary, System.IO.TextWriter, Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelperOptions) Initializes a new instance of
Microsoft.AspNetCore.Mvc.Rendering.ViewContext
.Arguments: - actionContext (Microsoft.AspNetCore.Mvc.ActionContext) – The
Microsoft.AspNetCore.Mvc.ActionContext
. - view (Microsoft.AspNetCore.Mvc.ViewEngines.IView) – The
Microsoft.AspNetCore.Mvc.ViewEngines.IView
being rendered. - viewData (Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary) – The
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
. - tempData (Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary) – The
Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary
. - writer (System.IO.TextWriter) – The
System.IO.TextWriter
to render output to. - htmlHelperOptions (Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelperOptions) – The
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelperOptions
to apply to this instance.
public ViewContext(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, TextWriter writer, HtmlHelperOptions htmlHelperOptions)
- actionContext (Microsoft.AspNetCore.Mvc.ActionContext) – The
-
ViewContext
(Microsoft.AspNetCore.Mvc.Rendering.ViewContext, Microsoft.AspNetCore.Mvc.ViewEngines.IView, Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, System.IO.TextWriter) Initializes a new instance of
Microsoft.AspNetCore.Mvc.Rendering.ViewContext
.Arguments: - viewContext (Microsoft.AspNetCore.Mvc.Rendering.ViewContext) – The
Microsoft.AspNetCore.Mvc.Rendering.ViewContext
to copy values from. - view (Microsoft.AspNetCore.Mvc.ViewEngines.IView) – The
Microsoft.AspNetCore.Mvc.ViewEngines.IView
being rendered. - viewData (Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary) – The
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
. - writer (System.IO.TextWriter) – The
System.IO.TextWriter
to render output to.
public ViewContext(ViewContext viewContext, IView view, ViewDataDictionary viewData, TextWriter writer)
- viewContext (Microsoft.AspNetCore.Mvc.Rendering.ViewContext) – The
-
Properties¶
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ClientValidationEnabled
¶ Gets or sets a value that indicates whether client-side validation is enabled.
Return type: System.Boolean public bool ClientValidationEnabled { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ExecutingFilePath
¶ Gets or sets the path of the view file currently being rendered.
Return type: System.String public string ExecutingFilePath { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
FormContext
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.FormContext
for the form element being rendered. A default context is returned if no form is currently being rendered.Return type: Microsoft.AspNetCore.Mvc.ViewFeatures.FormContext public virtual FormContext FormContext { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
Html5DateRenderingMode
¶ Set this property to
Microsoft.AspNetCore.Mvc.Rendering.Html5DateRenderingMode.Rfc3339
to have templated helpers such asMicrosoft.AspNetCore.Mvc.Rendering.IHtmlHelper.Editor(System.String,System.String,System.String,System.Object)
andMicrosoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1.EditorFor``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.String,System.String,System.Object)
render date and time values as RFC 3339 compliant strings. By default these helpers render dates and times using the current culture.Return type: Microsoft.AspNetCore.Mvc.Rendering.Html5DateRenderingMode public Html5DateRenderingMode Html5DateRenderingMode { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
TempData
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary
instance.Return type: Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionary public ITempDataDictionary TempData { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ValidationMessageElement
¶ Element name used to wrap a top-level message generated by
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.ValidationMessage(System.String,System.String,System.Object,System.String)
and other overloads.Return type: System.String public string ValidationMessageElement { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ValidationSummaryMessageElement
¶ Element name used to wrap a top-level message generated by
Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.ValidationSummary(System.Boolean,System.String,System.Object,System.String)
and other overloads.Return type: System.String public string ValidationSummaryMessageElement { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
View
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ViewEngines.IView
currently being rendered, if any.Return type: Microsoft.AspNetCore.Mvc.ViewEngines.IView public IView View { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ViewBag
¶ Gets the dynamic view bag.
Return type: System.Object public dynamic ViewBag { get; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
ViewData
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
.Return type: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary public ViewDataDictionary ViewData { get; set; }
-
Microsoft.AspNetCore.Mvc.Rendering.ViewContext.
Writer
¶ Gets or sets the
System.IO.TextWriter
used to write the output.Return type: System.IO.TextWriter public TextWriter Writer { get; set; }
-
Methods¶
-
GetFormContextForClientValidation
()¶ Return type: Microsoft.AspNetCore.Mvc.ViewFeatures.FormContext public FormContext GetFormContextForClientValidation()
-