-
January 6th, 2012, 12:17 PM
#1
using Response.Redirect() and posting at the same time
I'm trying to figure out how to post data in my C# codebehind while redirecting to another page. When the user clicks on a button in page1.aspx, he should be taken to page2.aspx. The C# codebehind of page2.aspx should be able to access a variable (a primary key) which is determined based on which button in page1.aspx was clicked. So page1.aspx needs to post the primary key that corresponds to that button, and page2.aspx needs to retrieve that primary key.
I'm not sure how to do this while redirecting from page1.aspx to page2.aspx using Response.Redirect(). I heard Server.Transfer() might be able to do it, but I'm at a loss there to in understanding how to use it.
The buttons in page1.aspx are in a table, which is in an ASP.NET content (i.e. <asp:content...>), which is declared/defined (I'm not sure what the right term is here) in a master page. All the contents in the master page are contained in a form. I mention this only because I've tried setting the method attribute in this form to "POST" without any luck, and also because you probably need to know the structure of my page.
So is there a way to redirect to another page from the C# codebehind while at the same time posting data to be retrieved by that other page?
-
January 9th, 2012, 07:05 PM
#2
Re: using Response.Redirect() and posting at the same time
Redirect tells the user's browser to go and get another page
UserBrowser> Hi server, give me page1's response to button1 being clicked
Server> Hi browser, request page2 from me
UserBrowser> Hi server, give me page 2
Server> Hi browser, here's some data: "this is page 2"
Server.Transfer gives another page responsibility for talking back to the browser
UserBrowser> Hi server, give me page1's response to button1 being clicked
Server> Hi browser, here's some data: "this is page 2"
See the difference?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|