Link to home
Start Free TrialLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

How to solve this problem of back button on browser.

I have the following code to save the data.
front end as
<table>
<tr>   <td class="td_style  report_color">
            <div align="center">
                <asp:Button ID="btnsave" runat="server" Text="Save Entry" onclick="btnsave_Click"
                     />
            </div>
            </td>
</tr>
<table>
in code behind
protected void btnsave_Click(object sender, EventArgs e)
    {
        try
        {
            btnsave.Enabled = false;
            if (chkconfirm.Checked == true)
            {
                cmd = new SqlCommand("savem1form", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = con;
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                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());
                cmd.ExecuteNonQuery();
                Response.Write("<script>alert('Record saved successfully')</script>");
                con.Close();
                callreset();

            }
        }
        catch (Exception ee)
        {
            Response.Write(ee.ToString());
        }
    }
-----------------------------------------------------------------------
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 asp.net using C#
ASKER CERTIFIED SOLUTION
Avatar of abhinayp86
abhinayp86
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of searchsanjaysharma
searchsanjaysharma

ASKER

ok