System.Web.UI.WebControls.Button.PostBackUrl Property

Gets or sets the URL of the page to post to from the current page when the System.Web.UI.WebControls.Button control is clicked.

Syntax

[System.Web.UI.UrlProperty("*.aspx")]
[System.Web.UI.Themeable(false)]
[System.ComponentModel.Editor("System.Web.UI.Design.UrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultValue("")]
public virtual string PostBackUrl { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

The Button.PostBackUrl property allows you to perform a cross-page post using the System.Web.UI.WebControls.Button control.

Note:

Only correctly specified paths work with this property. For example, relative paths (Test/default.aspx), absolute paths (https://localhost/WebApp/default.aspx) and virtual (~\Test\default.aspx) work correctly. Incorrectly formed paths such as "/Test/default.aspx" or "\Test\default.aspx" do not work. See ASP.NET Web Site Paths for a discussion on creating correct paths.

Set the Button.PostBackUrl property to the URL of the Web page to post to when the System.Web.UI.WebControls.Button control is clicked. For example, specifying Page2.aspx causes the page that contains the System.Web.UI.WebControls.Button control to post to Page2.aspx. If you do not specify a value for the Button.PostBackUrl property, the page posts back to itself.

Note:

When performing a cross-page postback with controls with server-side validation, you should check that the page's System.Web.UI.Page.IsValid property is true before processing the postback. In the case of a cross-page postback, the page to check is the System.Web.UI.Page.PreviousPage. The following VB code shows how this is done:

Example

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.PreviousPage.IsValid Then
            ' Handle the post back
        Else
            Response.Write("Invalid")
        End If
End Sub

For more information on cross-page posting techniques, see Cross-Page Posting in an ASP.NET Web Page.

This property cannot be set by themes or style sheet themes. For more information, see System.Web.UI.ThemeableAttribute and ASP.NET Themes Overview.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0