Prevent Form Resubmission [Resolved]

Posted by Sharpcnet under ASP.NET on 11/23/2013 | Points: 10 | Views : 6283 | Status : [Member] | Replies : 3
Is there any simple way to prevent form submission.
I have a page with a Fileupload control and a gridview. The file upload will upload an excel file. On Button click, all the records in excel will be saved to database and then , they are retieved to show in the gridview.
When user saves data, and then refreshes the button, the form resubmission prompt occurs. On clicking continue, the records in the excel are again saved to the database.

I tried setting fileupload1.dispose() to clear, but it still does it.
How can I prevent this.
Looking at the 'time technique' here, but want to know if there is a simpler way..
http://stackoverflow.com/questions/2283043/gridview-adds-duplicate-row-on-page-refresh/2283137#2283137
using c#. This is a sample how the flow is...

Page_load()
{
}
Button_Click
{
//if fileupload has file, save the data to gridview
......
bindgrid();
}
bindgrid()
{
//get data from database and show it in grid.
}





Responses

Posted by: vishalneeraj-24503 on: 11/23/2013 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Hi, please refer :-
http://stackoverflow.com/questions/14761382/prevent-form-resubmission-in-asp-net-without-redirecting-to-myself
http://stackoverflow.com/questions/1705135/preventing-re-submission-of-data-on-browser-refresh
http://stackoverflow.com/questions/542284/preventing-webform-resubmission-on-browser-refresh-without-losing-viewstate
http://stackoverflow.com/questions/2526568/asp-net-prevent-form-submission-twice
http://forums.asp.net/t/1891406.aspx?Prevent+Form+Resubmission+on+Refresh
http://forums.aspfree.com/web-layout-43/avoid-form-resubmission-when-refresh-clicked-23186.html
http://snipplr.com/view/35515/

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sharpcnet on: 11/24/2013 [Member] Starter | Points: 25

Up
0
Down
Thank you. One of the suggestions by "John Rasch", solved my problem. I had to redirect the user to the same page.
Button_Click

{

//if fileupload has file, save the data to gridview

......
Response.Redirect("~/SamePageUrl.aspx");
bindgrid();

}




Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 11/24/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
You most welcome.

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response