ASP.NET ဝဘ်စာမျက်နှာများ - အရာဝတ္ထုများ
ဝဘ်စာမျက်နှာများသည် Objects များအကြောင်း များသည်။
Page Object ၊
အသုံးပြုနေသည့် Page Object နည်းလမ်းအချို့ကို သင်မြင်ပြီးဖြစ်သည်-
@RenderPage("header.cshtml")
@RenderBody()
ယခင်အခန်းတွင် သင်အသုံးပြုနေသည့် စာမျက်နှာအရာဝတ္ထုဂုဏ်သတ္တိနှစ်ခု (IsPost၊ နှင့် Request) ကို သင်တွေ့ခဲ့ရသည်-
If (IsPost) {
if (Request["Choice"] != null) {
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. |
အချို့သော 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 |
စာမျက်နှာပိုင်ဆိုင်မှု (စာမျက်နှာအရာဝတ္ထု၏)
စာမျက်နှာအရာဝတ္တု၏ စာမျက်နှာပိုင်ဆိုင်မှုသည် စာမျက်နှာများနှင့် အပြင်အဆင်စာမျက်နှာများကြားတွင် မျှဝေထားသော ဒေတာအား ပိုင်ဆိုင်မှုကဲ့သို့ ဝင်ရောက်ခွင့်ပေးသည်။
သင်သည် စာမျက်နှာပိုင်ဆိုင်မှုသို့ သင်၏ကိုယ်ပိုင်ဂုဏ်သတ္တိများကို (ပေါင်းထည့်နိုင်သည်-
- စာမျက်နှာ။ခေါင်းစဉ်
- Page.Version
- Page. မင်းကြိုက်တဲ့ အရာ
စာမျက်နှာများပိုင်ဆိုင်မှုသည်အလွန်အသုံးဝင်သည်။ ဥပမာအားဖြင့်၊ ၎င်းသည် အကြောင်းအရာဖိုင်များတွင် စာမျက်နှာခေါင်းစဉ်ကို သတ်မှတ်နိုင်ပြီး အပြင်အဆင်ဖိုင်တွင် ၎င်းကို အသုံးပြုရန် ဖြစ်နိုင်စေသည်-
Home.cshtml
@{
Layout="~/Shared/Layout.cshtml";
Page.Title="Home Page"
}
<h1>Welcome to W3Schools</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>