We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

PostBackURL vs. Response.Redirect

What really is the difference between the two? and when should each of them be used? Can we use Response.Redirect in place of PostBackURL?

Thanks in advance.

5
Contributors
6
Replies
4 Years
Discussion Span
1 Year Ago
Last Updated
8
Views
c# seeker
Newbie Poster
7 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

PostBackURL is more equivalent to Server.Transfer than Response.Redirect.
It maintains ViewState and all the rest of the Page object and other State Bags.

Response.Redirect simply sends a 302 to the browser.

Also, PostBackURL simply sets a CLIENT-SIDE script event on a button. So it doesn't work in all situations. Server.Transfer stays on the server.

nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Skill Endorsements: 0

I tried PostBackURL and PreviousPage properties to get some values to another form. But I have to submit the page twice to go to the next page.

Why is that?

c# seeker
Newbie Poster
7 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Probably because you're setting PostBackURL in the same spot you're trying to use it.
PostBackURL is written out as client-side javascript on a button. If it is not set already at design time, you will see a need for 2 postbacks; one to set it and it gets written to the client, the next actually submits with the new PostBackURL.

nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Skill Endorsements: 0

how do I make my postbackurl link to the new webpage without clicking it twice

awasonia
Newbie Poster
2 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

PostBackURL sends all the form data to the assigned page.
Whereas when using Response.Redirect your sending the form data to your current page then moving your user to the assigned page.

So if your going to handle the form data on a separate page then you set the PostBackURL.
Otherwise, if your current page code handles the form data you do a Response.Redirect.

If you are using PostBackURL. Set it using the properties in the html/design view, or on page_load to make it work without clicking twice.

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
Skill Endorsements: 0

What really is the difference between the two? and when should each of them be used? Can we use Response.Redirect in place of PostBackURL?

Thanks in advance.

postback is most often used to process some code on server and calling the page itself again. whereas response.redirect is used to transfer control to another page.

ghazanfar381
Newbie Poster
3 posts since Jun 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.2995 seconds using 2.68MB