Table of Contents

Class ViewPage

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

Represents the properties and methods that are needed to render a view as a Web Forms page.

public class ViewPage : Page, IViewDataContainer
Inheritance
ViewPage
Implements
Derived

Constructors

ViewPage()

Initializes a new instance of the ViewPage class.

public ViewPage()

Properties

Ajax

Gets or sets the AjaxHelper object that is used to render HTML in Ajax scenarios.

public AjaxHelper<object> Ajax { get; set; }

Property Value

AjaxHelper<object>

The Ajax helper object that is associated with the view.

Html

Gets or sets the HtmlHelper object that is used to render HTML elements.

public HtmlHelper<object> Html { get; set; }

Property Value

HtmlHelper<object>

The HTML helper object that is associated with the view.

MasterLocation

Gets or sets the path of the master view.

public string MasterLocation { get; set; }

Property Value

string

The path of the master view.

Model

Gets the Model property of the associated ViewDataDictionary object.

public object Model { get; }

Property Value

object

The Model property of the associated ViewDataDictionary object.

TempData

Gets the temporary data to pass to the view.

public TempDataDictionary TempData { get; }

Property Value

TempDataDictionary

The temporary data to pass to the view.

Url

Gets or sets the URL of the rendered page.

public UrlHelper Url { get; set; }

Property Value

UrlHelper

The URL of the rendered page.

ViewBag

Gets the view bag.

public dynamic ViewBag { get; }

Property Value

dynamic

The view bag.

ViewContext

Gets or sets the information that is used to render the view.

public ViewContext ViewContext { get; set; }

Property Value

ViewContext

The information that is used to render the view, which includes the form context, the temporary data, and the view data of the associated view.

ViewData

Gets or sets a dictionary that contains data to pass between the controller and the view.

public ViewDataDictionary ViewData { get; set; }

Property Value

ViewDataDictionary

A dictionary that contains data to pass between the controller and the view.

Writer

Gets the text writer that is used to render the view to the response.

public HtmlTextWriter Writer { get; }

Property Value

HtmlTextWriter

The text writer that is used to render the view to the response.

Methods

InitHelpers()

Initializes the Ajax, Html, and Url properties.

public virtual void InitHelpers()

OnPreInit(EventArgs)

Raises the System.Web.UI.Page.PreInit event at the beginning of page initialization.

protected override void OnPreInit(EventArgs e)

Parameters

e EventArgs

The event data.

ProcessRequest(HttpContext)

Enables processing of the specified HTTP request by the ASP.NET MVC framework.

public override void ProcessRequest(HttpContext context)

Parameters

context HttpContext

An object that encapsulates HTTP-specific information about the current HTTP request.

Render(HtmlTextWriter)

Initializes the System.Web.UI.HtmlTextWriter object that receives the page content to be rendered.

protected override void Render(HtmlTextWriter writer)

Parameters

writer HtmlTextWriter

The object that receives the page content.

RenderView(ViewContext)

Renders the view page to the response using the specified view context.

public virtual void RenderView(ViewContext viewContext)

Parameters

viewContext ViewContext

An object that encapsulates the information that is required in order to render the view, which includes the controller context, form context, the temporary data, and the view data for the associated view.

SetTextWriter(TextWriter)

Note: This API is now obsolete.Sets the text writer that is used to render the view to the response.

[Obsolete("The TextWriter is now provided by the ViewContext object passed to the RenderView method.", true)]
public void SetTextWriter(TextWriter textWriter)

Parameters

textWriter TextWriter

The writer that is used to render the view to the response.

SetViewData(ViewDataDictionary)

Sets the view data dictionary for the associated view.

protected virtual void SetViewData(ViewDataDictionary viewData)

Parameters

viewData ViewDataDictionary

A dictionary of data to pass to the view.