pag 中各属性的介绍(官网.c#)
来源:互联网 发布:手机进程清理软件 编辑:程序博客网 时间:2024/05/17 08:45
命名空间: System.Web.UI
程序集: System.Web(在 system.web.dll 中)
Public Class Page Inherits TemplateControl Implements IHttpHandler
Dim instance As Page
public class Page : TemplateControl, IHttpHandler
public ref class Page : public TemplateControl, IHttpHandler
public class Page extends TemplateControl implements IHttpHandler
public class Page extends TemplateControl implements IHttpHandler
不适用。
Page 类与扩展名为 .aspx 的文件相关联。这些文件在运行时被编译为 Page 对象,并被缓存在服务器内存中。
如果要使用代码隐藏技术创建 Web 窗体页,请从该类派生。应用程序快速开发 (RAD) 设计器(如 Microsoft Visual Studio)自动使用此模型创建 Web 窗体页。
Page 对象充当页中所有服务器控件(实现
Page 类是一个用作 Web 应用程序的用户界面的控件,因此应对这样的类进行仔细检查以确保遵循编写安全代码和保证应用程序安全的最佳做法。有关这些主题的常规信息,请参见 Web 应用程序安全威胁概述、安全策略最佳实施策略 和 安全性的基础概念。有关更具体的信息,请参见 保证标准控件的安全、如何:显示安全错误信息、如何:通过对字符串应用 HTML 编码在 Web 应用程序中防止脚本侵入 和 验证控件介绍。
下面的代码示例演示如何在代码隐藏页模型中使用 Page 类。注意,代码隐藏源文件声明了一个从基页类继承的分部类。基页类可以是 Page,也可以是从 Page 派生的其他类。另外请注意,分部类允许代码隐藏文件使用页中定义的控件,而无需将其定义为字段成员。
Imports SystemPartial Class MyCodeBehindVB Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Place page-specific code here. End Sub ' Define a handler for the button click. Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click MySpan.InnerHtml = "Hello, " + MyTextBox.Text + "." End SubEnd Class
using System;public partial class MyCodeBehindCS : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { // Place page-specific code here. } // Define a handler for the button click. protected void SubmitBtn_Click(object sender, EventArgs e) { MySpan.InnerHtml = "Hello, " + MyTextBox.Text + "."; }}
下面的代码示例演示与前面的代码隐藏源文件对应的 .aspx 文件。
此示例有一个接受用户输入的文本框,这是一个潜在的安全威胁。默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。有关更多信息,请参见脚本侵入概述。
<%@ Page Language="VB" CodeFile="pageexample.aspx.vb" Inherits="MyCodeBehindVB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head runat="server"> <title>Page Class Example</title></head><body> <form id="form1" runat="server"> <div> <table> <tr> <td> Name: </td> <td> <asp:textbox id="MyTextBox" runat="server"/> </td> </tr> <tr> <td></td> <td><asp:button id="MyButton" text="Click Here" onclick="SubmitBtn_Click" runat="server"/></td> </tr> <tr> <td></td> <td><span id="MySpan" runat="server" /></td> </tr> </table> </div> </form></body></html>
<%@ Page Language="C#" CodeFile="pageexample.aspx.cs" Inherits="MyCodeBehindCS" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ><head runat="server"> <title>Page Class Example</title></head><body> <form id="form1" runat="server"> <div> <table> <tr> <td> Name: </td> <td> <asp:textbox id="MyTextBox" runat="server"/> </td> </tr> <tr> <td></td> <td><asp:button id="MyButton" text="Click Here" onclick="SubmitBtn_Click" runat="server"/></td> </tr> <tr> <td></td> <td><span id="MySpan" runat="server" /></td> </tr> </table> </div> </form></body></html>
必须使用 @ Page 指令并使用 Inherits 和 CodeFile 属性将代码隐藏文件链接至 .aspx 文件。在此示例中,Inherits 属性指示 MyCodeBehind 类,CodeFile 属性指示包含该类的语言特定的文件的路径。
下面的代码示例演示单文件页模型以及如何访问 Page 的 IsPostBack 属性和 Response 属性。
<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim sb As New StringBuilder() If (Page.IsPostBack) Then sb.Append("You posted back to the page.<br />") End If sb.Append("The host address is " + Page.Request.UserHostAddress + ".<br />") sb.Append("The page title is """ + Page.Header.Title + """.") PageMessage.Text = sb.ToString() End Sub </script><html ><head runat="server"> <title>Page Class Example</title></head><body> <form id="form1" runat="server"> <div> <asp:Label id="PageMessage" runat="server"/> <br /> <br /> <asp:Button id="PageButton" Text="PostBack" runat="server" /> </div> </form></body></html>
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); if (Page.IsPostBack) sb.Append("You posted back to the page.<br />"); sb.Append("The host address is " + Page.Request.UserHostAddress + ".<br />"); sb.Append("The page title is /"" + Page.Header.Title + "/"."); PageMessage.Text = sb.ToString(); }</script><html ><head runat="server"> <title>Page Class Example</title></head><body> <form id="form1" runat="server"> <div> <asp:Label id="PageMessage" runat="server"/> <br /> <br /> <asp:Button id="PageButton" Text="PostBack" runat="server" /> </div> </form></body></html>
- AspNetHostingPermission 用于在宿主环境中进行操作。要求值:InheritanceDemand;权限值:Minimal。
System.Web.UI.Control
System.Web.UI.TemplateControl
System.Web.UI.Page
System.Web.UI.MobileControls.MobilePage
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。
版本信息.NET Framework
受以下版本支持:3.0、2.0、1.1、1.0- pag 中各属性的介绍(官网.c#)
- pag 中各属性的介绍(官网.c#)
- 第三章 Backbonejs中的Collections实践 上一节介绍了model的使用,model算是对现实中某一物体的抽象,比如你可以定义一本书的model,具有书名(title)还有书页(pag
- 查看PAG的使用情况
- Objective-c的@property,属性介绍
- Qt creator 中 tab widget 修改pag名字
- Objective-C属性介绍
- Objective-C属性介绍
- Objective-C属性介绍
- Objective-C属性介绍
- ios开发中@property的属性介绍
- CSS中Zoom属性的一些介绍
- CSS中Zoom属性的一些介绍
- ios开发中@property的属性介绍
- CSS中Position的属性介绍
- Ibatis配置文件中属性的介绍
- iOS开发中@property的属性介绍
- hibernate中<key>的属性介绍
- ASP生成静态页面方法
- pag 中各属性的介绍(官网.c#)
- Linux系统管理、应用与开发实践教程 - 图书目录
- 在MIDP1.0中简单模拟图片翻转功能
- jsp upload package "MultipartRequest and MultipartParser"的license是一本书,呵呵,有趣
- pag 中各属性的介绍(官网.c#)
- 几行代码轻松让你的界面与众不同(for vc)
- ACE_Select_Reactor的Notify功能实现浅析
- RHEL5实现高可用HA集群+GFS+EnterpriseDB
- 数字电路笔试题目1
- UNIX高手的十个习惯
- 英语短语爱情60篇
- Ehcache的配置说明
- 连续自然数之和问题(多种解法)