ASP. NET Web Pages-object, asp. netpages

Source: Internet
Author: User

ASP. NET Web Pages-object, asp. netpages

Web Pages are usually related to objects.

Page Object

You have seen some used Page objects:

@RenderPage("header.cshtml")@RenderBody()

In the previous chapter, you have seen two used Page Object Attributes (isPost and Request ):

If (isPost) {if (Request["Choice"] != null {

Page Object Methods

Method Description
Href Build a URL with the specified parameters.
RenderBody () In the layout page, the content page section is not in the specified part.
RenderPage (page) The content of a page is displayed on another page.
RenderSection (section) The specified content is displayed on the layout page.
Write (object) Write the specified object as an HTML-encoded string.
WriteLiteral The specified object can be written without HTML encoding.

Page Object Attributes

Attribute Description
IsPost Returns a value (true or false) indicating whether the HTTP data transmission method used by the client to request a webpage is a POST request.
Layout Gets or sets the path of the layout page.
Page Provides access to similar attributes of page data shared between pages, layout pages, and pages.
Request Obtain the HttpRequest object of the current HTTP request.
Server Obtain the HttpServerUtility object. The method provided by this object can be used during webpage processing.

Page attribute (of the Page Object)

The Page attribute of the Page object, which provides access to similar attributes of Page data shared between pages, layout pages, and pages.

You can add (use) your own attributes like Page attributes:

  • Page. Title
  • Page. Version
  • Page. anythingyoulike

The Page attribute is useful. For example, you can set the page title in the Content File and use it in the layout file:

Home. cshtml
@{Layout="~/Shared/Layout.cshtml";Page.Title="Home Page"}Layout. cshtml
<!DOCTYPE html>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.