if(!IsPostBack)的作用都有那些?

解决方案 »

  1.   

    获取一个值,该值指示该页是否正为响应客户端回发而加载,或者它是否正被首次加载和访问。[Visual Basic]
    Public ReadOnly Property IsPostBack As Boolean[C#]
    public bool IsPostBack {get;}[C++]
    public: __property bool get_IsPostBack();[JScript]
    public function get IsPostBack() : Boolean;属性值
    如果是为响应客户端回发而加载该页,则为 true;否则为 false。示例
    [Visual Basic, C#, JScript] 下面的示例测试 IsPostBack 属性的值以在加载了 Page 时按条件为所有验证服务器控件调用 Page.Validate 方法。[Visual Basic] 
    Sub Page_Load
        If Not IsPostBack
            ' Validate initially to force the asterisks
    ' to appear before the first roundtrip.
            Validate()
        End If
    End Sub[C#] 
    void Page_Load() {
        if (!IsPostBack) {
            // Validate initially to force asterisks
    // to appear before the first roundtrip.
            Validate();
        }
    }[JScript] 
    function Page_Load() {
        if (!IsPostBack) {
            // Validate initially to force the asterisks
    // to appear before the first roundtrip.
            Validate();
        }
    }[C++] 没有可用于 C++ 的示例。若要查看 Visual Basic、C# 或 JScript 示例,请单击页左上角的“语言筛选器”按钮 。要求
    平台: Windows 2000, Windows XP Professional, Windows Server 2003 系列请参见
    Page 类 | Page 成员 | System.Web.UI 命名空间 | Page 成员(Visual J# 语法) | C++ 托管扩展编程 
    --------------------------------------------------------------------------------
      

  2.   

    if(!IsPostBack)
    {
    //第一次加载该页面的时候会执行下面的代码;
       XXXXXXXXXXXXXXXX
    }