ASP And ASP.NET Tutorials
- ASP.NET Web Pages - Tutorial
- ASP.NET Web Pages - Adding Razor Code
- ASP.NET Web Pages - Page Layout
- ASP.NET Web Pages - Folders
- ASP.NET Web Pages - Global Pages
- ASP.NET Web Pages - HTML Forms
- ASP.NET Web Pages - Objects
- ASP.NET Web Pages - Files
- ASP.NET Web Pages - Databases
- ASP.NET Web Pages - Helpers
- ASP.NET Web Pages - The WebGrid Helper
- ASP.NET Web Pages - The Chart Helper
- ASP.NET Web Pages - The WebMail Helper
- ASP.NET Web Pages - WebSecurity Object
- ASP.NET Web Pages - Publishing The Website
- ASP.NET Web Pages - Classes
- ASP.NET Razor - Markup
- ASP.NET Razor - C# And VB Code Syntax
- ASP.NET Razor - C# Variables
- ASP.NET Razor - C# Loops And Arrays
- ASP.NET Razor - C# Logic Conditions
- ASP.NET Razor - VB Variables
- ASP.NET Razor - VB Loops And Arrays
- ASP.NET Razor - VB Logic Conditions
- ASP Tutorial
- ASP Syntax
- ASP Variables
- ASP Procedures
- VBScript Conditional Statements
- VBScript Looping
- ASP Forms And User Input
- ASP Cookies
- ASP Session Object
- ASP Application Object
- ASP Including Files
- ASP The Global.asa File
- ASP AJAX
- ASP Sending E-mail With CDOSYS
- VBScript Functions
- VBScript Keywords
- ASP Response Object
- ASP Application Object
- ASP Session Object
- ASP Server Object
- ASP ASPError Object
- ASP FileSystemObject Object
- ASP TextStream Object
- ASP Drive Object
- ASP File Object
- ASP Folder Object
- ASP Dictionary Object
- ASP AdRotator Component
- ASP Browser Capabilities Component
- ASP Content Linking Component
- ASP Content Rotator Component (ASP 3.0)
- ASP Quick Reference
- ADO Introduction
- ADO Database Connection
- ADO Recordset
- ADO Display
- ADO Queries
- ADO Sort
- ADO Add Records
- ADO Update Records
- ADO Delete Records
- ADO Demonstration
- ADO Speed Up With GetString()
- ADO Command Object
- ADO Connection Object
- ADO Error Object
- ADO Field Object
- ADO Parameter Object
- ADO Property Object
- ADO Record Object
- ADO Recordset Object
- ADO Stream Object
- ADO Data Types
ASP.NET Web Pages - Objects
The Page Object
You have already seen some Page Object methods in use:
@RenderPage("header.cshtml")
@RenderBody()
@RenderBody()
In the previous chapter you saw two Page Object properties being used (IsPost, and Request):
If (IsPost) {
if (Request["Choice"] != null) {
if (Request["Choice"] != null) {
Practice Excercise Practice now
Some Page Object Methods
Method | Description |
---|---|
href | Builds a URL using the specified parameters |
RenderBody() | Renders the portion of a content page that is not within a named section (In layout pages) |
RenderPage(page) | Renders the content of one page within another page |
RenderSection(section) | Renders the content of a named section (In layout pages) |
Write(object) | Writes the object as an HTML-encoded string |
WriteLiteral | Writes an object without HTML-encoding it first. |
Practice Excercise Practice now
Some Page Object Properties
Property | Description |
---|---|
IsPost | Returns true if the HTTP data transfer method used by the client is a POST request |
Layout | Gets or sets the path of a layout page |
Page | Provides property-like access to data shared between pages and layout pages |
Request | Gets the HttpRequest object for the current HTTP request |
Server | Gets the HttpServerUtility object that provides web-page processing methods |
Practice Excercise Practice now
The Page Property (of The Page Object)
The Page property of the Page Object, provides property-like 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
The pages property is very helpful. For instance, it makes it possible to set the page title in content files, and use it in the layout file:
Home.cshtml
@{
Layout="~/Shared/Layout.cshtml";
Page.Title="Home Page"
}
<h1>Welcome to mytat</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="~/Shared/Layout.cshtml";
Page.Title="Home Page"
}
<h1>Welcome to mytat</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>
<html>
<head>
<title>@Page.Title</title>
</head>
<body>
@RenderBody()
</body>
</html>
Practice Excercise Practice now
Products
Partner
Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP