Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 How to: Post ASP.NET Web Pages to a...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
ASP.NET
How to: Post ASP.NET Web Pages to a Different Page

By default, controls on ASP.NET Web 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 page. For example, you might be creating a multi-page form that collects different information on each page.

On the target page, you can read the values of controls or public properties from the source page. For more information, see Cross-Page Posting in ASP.NET Web Pages.

To post an ASP.NET Web page to another page

  1. Add a button control to your Web 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 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 Pages.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Determining the names of the items in the forms collection      Orpheus ... Thomas Lee   |   Edit   |   Show History

If you are using a master page, determining the names of the items in the forms collection can be difficult. You can use the code below to create an Excel spreadsheet of the form item names and values.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition", "attachment; filename=Form Collection.xls")
Page.EnableViewState = False
        sbHTML.Append("<table border=""0"" cellpadding=""3"" style=""border-collapse: collapse"" width=""100%"" bordercolor=""#000000"" id=""table1"">" & Environment.NewLine)
sbHTML.Append("<tr>" & Environment.NewLine)
sbHTML.Append("<td bgcolor=""black"" colspan=""2""><b><font face=""Arial"" color=""white"" size=""4"">Form Collection</font></b></td>" & Environment.NewLine)
sbHTML.Append("</tr>" & Environment.NewLine)
sbHTML.Append("<tr>" & Environment.NewLine)
sbHTML.Append("<th>Name</th>" & Environment.NewLine)
sbHTML.Append("<th>Value</th>" & Environment.NewLine)
sbHTML.Append("</tr>" & Environment.NewLine)
        Dim i As Integer
For i = 0 To Request.Form.Count - 1
sbHTML.Append("<tr>" & Environment.NewLine)
sbHTML.Append("<td height=19>" & Request.Form.AllKeys(i) & "</td>" & Environment.NewLine)
sbHTML.Append("<td height=19>" & Request.Form(i) & "</td>" & Environment.NewLine)
sbHTML.Append("</tr>" & Environment.NewLine)
Next
        sbHTML.Append("</table>" & Environment.NewLine)
'Debug.WriteLine(sbHTML.ToString())
Response.Write(sbHTML.ToString())
Response.End()
End Sub
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker