How to solve this problem of back button on browser.

Posted on 2012-08-10
Last Modified: 2012-08-28
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#
Question by:searchsanjaysharma
    LVL 9

    Accepted Solution

    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

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now