Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1525
  • Last Modified:

page refresh with response.redirect vs server.transfer

ASP.NET 2.0 VS2005

I have an ASP.NET application that is highly transactional. i.e about 20 text boxes on each page and data collected from each page updated to a SQL database . Lets call one of the pages  myPage.aspx.  The user enters data for the 20 or so textboxes and the hits an "Update" button which inserts a record to the SQL database. The users needs to start the next record.

Currently I am simply using  response.redirect("myPage.aspx") to reload the page and effectively clear the text boxes ready for the next transaction.

Is reloading the page with respons.redirect the best way of refreshing page textboxes and datagrids?

I am considering server.transfer("myPage.aspx") because it is more economical but it seems odd. i.e to  transfer page 'focus' on itself. I have only used this when progessing to another page and not for page reload.

I just need advise on what would be the best practice in a case like this.
0
JenebyM
Asked:
JenebyM
  • 2
2 Solutions
 
DhaestCommented:
Why don't you clear all your textboxes after saving ?
0
 
JenebyMAuthor Commented:
Because I found page reload clears 20 boxes with one line of code. If i used clear for 13 pages i would need to track clearing of 13 X 20 text boxes instead of 13 lines of code.

Additionally there are labels on the page which change mid-way through processing that need to revert to beginging of transaction.

Is clearing that number of textboxes and labes  faster than reloading the page with  redirect?
 
0
 
ggable313Commented:
Here are some discussions about the differences of the 2:

"So, in brief: Response.Redirect simply tells the browser to visit another page. Server.Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables."  from the following link:
http://www.developer.com/net/asp/article.php/3299641

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=15

"Response.redirect provides a roundtrip to the server and server.transfer does not. For details search microsoft IIS help

Also Response.redirect redirects both the html page as well as the aspx page where as the server.transfer  transfers the  control only to the aspx pages"  from
http://www.geekinterview.com/question_details/15806

http://weblogs.asp.net/jgalloway/archive/2004/07/21/189547.aspx  (This one is actually in favor of Server.Transfer sometimes)

Anyway, hopefully this can help you make your decision
0
 
JenebyMAuthor Commented:
I have looked at the differences between  the two before coming to post.

However, the question I am grappling with is NOT the differences during  navigation from one page to next.

The issues is using either on the SAME page to reload on postback. I.e the current page is myPage.aspx and I use reponse.redirect("myPage.aspx") to reload the SAME page. I have found that reloading the page this way is the easiest way to clear the text values preparatory to the next transaction on the same page after the record is updated.

Is this the only way to reload. (In effect I am looking for the equivalent of page.refresh from winforms)

Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now