Table of Contents

Class ViewContext

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Encapsulates information that is related to rendering a view.

public class ViewContext : ControllerContext
Inheritance
ViewContext
Inherited Members

Constructors

ViewContext()

Initializes a new instance of the ViewContext class.

public ViewContext()

ViewContext(ControllerContext, IView, ViewDataDictionary, TempDataDictionary, TextWriter)

Initializes a new instance of the ViewContext class by using the specified controller context, view, view data dictionary, temporary data dictionary, and text writer.

public ViewContext(ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData, TextWriter writer)

Parameters

controllerContext ControllerContext

Encapsulates information about the HTTP request.

view IView

The view to render.

viewData ViewDataDictionary

The dictionary that contains the data that is required in order to render the view.

tempData TempDataDictionary

The dictionary that contains temporary data for the view.

writer TextWriter

The text writer object that is used to write HTML output.

Exceptions

ArgumentNullException

One of the parameters is null.

Properties

ClientValidationEnabled

Gets or sets a value that indicates whether client-side validation is enabled.

public virtual bool ClientValidationEnabled { get; set; }

Property Value

bool

true if client-side validation is enabled; otherwise, false.

FormContext

Gets or sets an object that encapsulates information that is required in order to validate and process the input data from an HTML form.

public virtual FormContext FormContext { get; set; }

Property Value

FormContext

An object that encapsulates information that is required in order to validate and process the input data from an HTML form.

TempData

Gets data that is associated with this request and that is available for only one request.

public virtual TempDataDictionary TempData { get; set; }

Property Value

TempDataDictionary

The temporary data.

UnobtrusiveJavaScriptEnabled

Gets or sets a value that indicates whether unobtrusive JavaScript is enabled.

public virtual bool UnobtrusiveJavaScriptEnabled { get; set; }

Property Value

bool

true if unobtrusive JavaScript is enabled; otherwise, false.

ValidationMessageElement

Element name used to wrap a top-level message generated by ValidationMessage(HtmlHelper, string) and other overloads.

public virtual string ValidationMessageElement { get; set; }

Property Value

string

ValidationSummaryMessageElement

Element name used to wrap a top-level message generated by ValidationSummary(HtmlHelper) and other overloads.

public virtual string ValidationSummaryMessageElement { get; set; }

Property Value

string

View

Gets an object that implements the IView interface to render in the browser.

public virtual IView View { get; set; }

Property Value

IView

The view.

ViewBag

Gets the dynamic view data dictionary.

public dynamic ViewBag { get; }

Property Value

dynamic

The dynamic view data dictionary.

ViewData

Gets the view data that is passed to the view.

public virtual ViewDataDictionary ViewData { get; set; }

Property Value

ViewDataDictionary

The view data.

Writer

Gets or sets the text writer object that is used to write HTML output.

public virtual TextWriter Writer { get; set; }

Property Value

TextWriter

The object that is used to write the HTML output.

Methods

OutputClientValidation()

Writes the client validation information to the HTTP response.

public void OutputClientValidation()