views:

1043

answers:

2

Hi, Whats the normal procedure of clearing a form after POST? Just loop through the textboxes and cleat all text? I have an ASP.NET application with several forms and I am trying to avoid them sending the data twice?

Thanks

+1  A: 

You can inject some javascript code to execute after postback.

document.forms[0].reset();
document.forms[1].reset();

From server side, I haven't found an easy way to reset the form contents other than iterating through the controls inside a loop or doing a Server.Transfer back to the same page.

Gulzar
+5  A: 

You can avoid double sending/doing by putting your code inside an if(!isPostBack) block. This will tell the page not to do the specified actions when posting.

ZCHudson
You are correct. That helped with the dual posting. If the users click a new page and then use the browser back button to go back to the form, can they do a re-post?
Saif Khan