How to solve this problem of back button on browser.

I have the following code to save the data.
front end as
<tr>   <td class="td_style  report_color">
            <div align="center">
                <asp:Button ID="btnsave" runat="server" Text="Save Entry" onclick="btnsave_Click"
in code behind
protected void btnsave_Click(object sender, EventArgs e)
            btnsave.Enabled = false;
            if (chkconfirm.Checked == true)
                cmd = new SqlCommand("savem1form", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = con;
                if (con.State == ConnectionState.Closed)
                cmd.Parameters.AddWithValue("@source", txtsource.Text.Trim());
                cmd.Parameters.AddWithValue("@state", txtstate.Text.Trim());
                cmd.Parameters.AddWithValue("@district", ddldistricts.SelectedItem.Text.Trim());
                cmd.Parameters.AddWithValue("@phc_chc_name", txtphc_chc_name.Text.Trim());
                cmd.Parameters.AddWithValue("@sub_centre", txtsub_centre.Text.Trim());
                cmd.Parameters.AddWithValue("@village", txtvillage.Text.Trim());
                cmd.Parameters.AddWithValue("@chv_name", txtchvname.Text.Trim());
                cmd.Parameters.AddWithValue("@uin", Convert.ToInt32(ddluin.SelectedItem.Text.Trim()));
                cmd.Parameters.AddWithValue("@sno", txtsno.Value);
                cmd.Parameters.AddWithValue("@patient", txtpatient.Text.Trim());
                cmd.Parameters.AddWithValue("@hof", txthof.Text.Trim());
                Response.Write("<script>alert('Record saved successfully')</script>");

        catch (Exception ee)
When the user clicks on btnsave, the data gets saved, the message comes as Record Saved Successfully, then the user is directed on same page
with save button ge tting disabled and new button getting activated, then the user add the data and save gets activated and the process is repeated.

The problem is when the user clicks on is returned on same page, if presses back button all the values are there and he can press save button as many time.
I want to make this work like as the that when the user clicks on back button of browser the page should be lost.Is it possible.

Like when we pay online payment the old pages gets lost.

I am using using C#
Who is Participating?
abhinayp86Connect With a Mentor Commented:
One way is to refresh the page completely whenever user clicks on the back button (basically on every load)

public class ProductBrowser : Page
    protected override void OnInit(EventArgs e)


Open in new window
searchsanjaysharmaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.