pag 中各属性的介绍(官网.c#)

Page 类
表示从 ASP.NET Web 应用程序的宿主服务器请求的 .aspx 文件(又称为 Web 窗体页)。

命名空间: System.Web.UI
程序集: System.Web(在 system.web.dll 中)

<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl0954c2ffd,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl09img,"; </script> 语法语法
Visual Basic(声明)
Public Class Page
    Inherits TemplateControl
    Implements IHttpHandler
Visual Basic (用法)
Dim instance As Page
C#
public class Page : TemplateControl, IHttpHandler
C++
public ref class Page : public TemplateControl, IHttpHandler
J#
public class Page extends TemplateControl implements IHttpHandler
JScript
public class Page extends TemplateControl implements IHttpHandler
XAML
不适用。
备注备注

Page 类与扩展名为 .aspx 的文件相关联。这些文件在运行时被编译为 Page 对象,并被缓存在服务器内存中。

如果要使用代码隐藏技术创建 Web 窗体页,请从该类派生。应用程序快速开发 (RAD) 设计器(如 Microsoft Visual Studio)自动使用此模型创建 Web 窗体页。

Page 对象充当页中所有服务器控件(实现

Page 类是一个用作 Web 应用程序的用户界面的控件,因此应对这样的类进行仔细检查以确保遵循编写安全代码和保证应用程序安全的最佳做法。有关这些主题的常规信息,请参见 Web 应用程序安全威胁概述安全策略最佳实施策略安全性的基础概念。有关更具体的信息,请参见 保证标准控件的安全如何:显示安全错误信息如何:通过对字符串应用 HTML 编码在 Web 应用程序中防止脚本侵入验证控件介绍

TopicLocation
How to: Determine How ASP.NET Web Pages Were Invoked在 Visual Studio 中构建 ASP .NET Web 应用程序
How to: Locate the Web Forms Controls on a Page by Walking the Controls Collection在 Visual Studio 中构建 ASP .NET Web 应用程序
如何:确定调用 ASP.NET 网页的方式生成 ASP .NET Web 应用程序
如何:通过遍历控件集合定位页上的 Web 窗体控件生成 ASP .NET Web 应用程序
演练:为移动设备创建网页在 Visual Studio 中构建 ASP .NET Web 应用程序
INamingContainer 接口的控件或实现此接口的控件的子控件除外)的命名容器。
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl1733d01f2,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl17img,"; </script>
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl3289ff147,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl32img,"; </script> 示例示例

下面的代码示例演示与前面的代码隐藏源文件对应的 .aspx 文件。

安全说明安全注意:

此示例有一个接受用户输入的文本框,这是一个潜在的安全威胁。默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。有关更多信息,请参见脚本侵入概述

Visual Basic
<%@ 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" οnclick="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" οnclick="SubmitBtn_Click" runat="server"/></td>
          </tr>
          <tr>
             <td></td>
             <td><span id="MySpan" runat="server" /></td>
          </tr>
       </table>     
    </div>
    </form>
</body>
</html>

必须使用 @ Page 指令并使用 InheritsCodeFile 属性将代码隐藏文件链接至 .aspx 文件。在此示例中,Inherits 属性指示 MyCodeBehind 类,CodeFile 属性指示包含该类的语言特定的文件的路径。

下面的代码示例演示单文件页模型以及如何访问 PageIsPostBack 属性和 Response 属性。

Visual Basic
<%@ 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>
复制代码
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl434260698,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl43img,"; </script> .NET Framework 安全性.NET Framework 安全性
AspNetHostingPermission  用于在宿主环境中进行操作。要求值: LinkDemand;权限值: Minimal
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl48ce0dc75,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl48img,"; </script> 继承层次结构继承层次结构
System.Object
   System.Web.UI.Control
     System.Web.UI.TemplateControl
       System.Web.UI.Page
         System.Web.UI.MobileControls.MobilePage
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl54908bb45,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl54img,"; </script>
<script type="text/Javascript"> var ExpCollDivStr = ExpCollDivStr; ExpCollDivStr = ExpCollDivStr + "ctl00_LibFrame_ctl552f29284,"; var ExpCollImgStr = ExpCollImgStr; ExpCollImgStr = ExpCollImgStr + "ctl00_LibFrame_ctl55img,"; </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值