共用方式為


How to: Post ASP.NET Web Forms Page to a Different Page

By default, server controls on ASP.NET Web Forms pages that cause a postback, such as the Button control, post back to the page for processing. However, you can configure controls to post to a different Web Forms page. For example, you might be creating a multi-page form that collects different information on each page. On the target Web Forms page, you can read the values of controls or public properties from the source Web Forms page. For more information, see Cross-Page Posting in ASP.NET Web Forms.

Note

This topic applies only to ASP.NET Web Forms pages. It does not apply to pages that you create using ASP.NET MVC (Model View Controller) or ASP.NET Web Pages.

To post an ASP.NET Web Forms page to another Web Forms page

  1. Add a button control to your Web Forms page, such as a Button, LinkButton, or ImageButton control.

  2. Set the PostBackUrl property for the control to the URL of the page to which you want to post the ASP.NET Web Forms page.

    The following code example illustrates a Button control that is configured to post to a page named TargetPage in the root of the Web site.

    <asp:Button 
      ID="Button1" 
      PostBackUrl="~/TargetPage.aspx"
      runat="server"
      Text="Submit" />
    

    For more information, see How to: Pass Values Between ASP.NET Web Forms Pages.

See Also

Tasks

How to: Pass Values Between ASP.NET Web Forms Pages

How to: Determine How ASP.NET Web Forms Were Invoked

Concepts

Redirecting Users to Another Web Forms Page

Cross-Page Posting in ASP.NET Web Forms