ASP.NET Tutoria...login
ASP.NET Tutorial
author:php.cn  update time:2022-04-11 14:18:18

Web Pages object


ASP.NET Web Pages -Objects


Web Pages are often related to objects.


Page Object

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

@RenderPage("header.cshtml")

@RenderBody()

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

If (isPost) {

if (Request["Choice"] != null {


Some Page object methods

##hrefCreates a URL using the specified value ##. #RenderBody()##RenderPage(page)section)##Write()Write the object as an HTML-encoded string. Priority is not to use HTML encoding when writing objects ##Some Page object properties.
MethodDescription
Renders a part of the content page that is not in the named area of ​​the layout page.
Render the content of a certain page in another page ##RenderSection(
Render. The contents of the named area of ​​the layout page. object
#WriteLiteral

Attribute

Description

isPost##Layout Gets or sets the path of the layout page. #Page Provides similar property access to data shared between pages and layout pages ##Request#ServerGet the HttpServerUtility object, which provides web page processing methods.

The Page property of the Page object

The Page property of the Page object provides similar property access to data shared between pages and layout pages.

You can use (add) your own properties to the Page property:

  • Page.Title

  • Page.Version

  • Page.anythingyoulike

Page properties are very useful. For example, 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"
}


<h1>Welcome to W3CSchool.cc</h1>

<h2>Web Site Main Ingredients</h2>

<p>A Home Page (Default.cshtml)< ;/p>
<p>A Layout File (Layout.cshtml)</p>
<p>A Style Sheet (Site.css)</p>

Layout.cshtml

<!DOCTYPE html>
<html>
<head>
<title>@Page.Title</title>
</head>
<body>
@RenderBody()
</body>
</html


If the client uses If the HTTP data transmission method is a POST request, true will be returned.
Obtained for the current HTTP request. HttpRequest object.