Easy Tutorial
❮ Prop Webcontrol Checkboxlist Repeatcolumns Razor Vb Loops ❯

ASP.NET Web Pages - Objects


Web Pages often involve objects.


Page Object

You have already seen some methods of the Page object in use:

In previous sections, you have seen two properties of the Page object (isPost and Request):


Certain Page Object Methods

Method Description
href Creates a URL with the specified values.
RenderBody() Renders a part of the content page that is not in a named section of the layout page.
RenderPage(page) Renders the content of one page within another page.
RenderSection(section) Renders the content of a named section in the layout page.
Write(object) Writes the object as an HTML-encoded string.
WriteLiteral Writes the object without HTML encoding.

Certain Page Object Properties

Property Description
isPost Returns true if the client uses the HTTP POST method.
Layout Gets or sets the path of the layout page.
Page Provides property-like access to shared data between the page and the layout page.
Request Gets the HttpRequest object for the current HTTP request.
Server Gets the HttpServerUtility object, which provides web processing methods.

Page Object's Page Property

The Page property of the Page object provides property-like access to shared data between the page and the layout page.

You can add your own properties to the Page property:

Page properties are very useful. For example, setting the page title in the content file and using it in the layout file:

Home.cshtml

@{Layout="~/Shared/Layout.cshtml";Page.Title="Home Page"}

Layout.cshtml

<title>@Page.Title</title>
@RenderBody()
❮ Prop Webcontrol Checkboxlist Repeatcolumns Razor Vb Loops ❯