Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a Form which contains :
Category TextBox
Button to Save the TextBox value in database.

The code works fine, all textbox value get Saved successfully on Save Button Click.

Problem:
After Saving I redirect to same page, and now here when I click on some link suppose 'Google.Com' and then if I click back button the browser redirect me to previous page on my application. on Click on Back Button the Postback value is found to be True, and again Save Button Event gets Fired.

I don't want the event must get fired on back click and again textbox value gets saved in database.
What should I do?

Please help me , I m getting issue and not getting solution on it.
Posted
Updated 24-Aug-13 6:17am
v2
Comments
Mahesh Bailwal 24-Aug-13 14:24pm    
I tried the same scenario what you mentioned, it did not post back in my case when I clicked browser back button.

Can you share your code and tell which browser are you using.

GOT SOLUTION FROM Other SITE

What you need to do is to implement a Post/Redirect/Get (PRG) pattern in your app. The basic rule is that your POST should not return a page (or a view); instead, it should return just a redirect request that will GET the page/view to show.

While you'll find a lot more information about PRG in relation to ASP.NET MVC, I'm assuming your working with web forms - so there's not much in terms of examples out there that I'm familiar with.

But the concept is pretty straight-forward. After your POST, just return a Response.Redirect back to the page that you want to display. It may seem like duplicate work, but you'll save yourself the problems that you're describing.
 
Share this answer
 
Put your insert code in if(!ispostback) {}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900