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:
public ViewContext(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, TextWriter writer, HtmlHelperOptions htmlHelperOptions)
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:
public ViewContext(ViewContext viewContext, IView view, ViewDataDictionary viewData, TextWriter writer)

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 as Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.Editor(System.String,System.String,System.String,System.Object) and Microsoft.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()