When you click a button in ASP.NET, it POSTS to itself and calls the btnXXX_click function. \ One way to make it go to another .aspx page on click is to call Server.Transfer or Response.Redirect \ from within that btnXXX_click function, but no form variables will be passed along.
I want to goto a btnXXX_Click function when the button is clicked, then do some stuff, then redirect \ to another page along with the form variables Doing a Server.Transfer or Response.Redirect will NOT transfer \ the form variables with it.
What we have to do, is take those forms, convert them into context items, then call the .aspx page we want \ with Server.Transfer.
To add all forms into the context.Items:
Private Sub btnGenReports_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenReports.Click Dim strUrl as String = "posttothispage.aspx" 'Copy all request objects into Context Items for next page (make-shift POST method) For Each r As String In Request.Params 'params are all the request object names (not values) context.Items.Add(r, Request(r)) 'request(param name) is the value of the request object Next Server.Transfer(strUrlResults) ' or use Response.Redirect(strUrlResults) End Sub
Now, in 'posttothispage.aspx', you would access those forms by:
context.Items("nameOfFormHere")
This is a "Make Shift" POST method in ASP.NET by mReschke 08:55, 10 October 2007 (CDT)