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.StoredProcedur e;
cmd.Connection = con;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.Parameters.AddWithValu e("@source ", txtsource.Text.Trim());
cmd.Parameters.AddWithValu e("@state" , txtstate.Text.Trim());
cmd.Parameters.AddWithValu e("@distri ct", ddldistricts.SelectedItem. Text.Trim( ));
cmd.Parameters.AddWithValu e("@phc_ch c_name", txtphc_chc_name.Text.Trim( ));
cmd.Parameters.AddWithValu e("@sub_ce ntre", txtsub_centre.Text.Trim()) ;
cmd.Parameters.AddWithValu e("@villag e", txtvillage.Text.Trim());
cmd.Parameters.AddWithValu e("@chv_na me", txtchvname.Text.Trim());
cmd.Parameters.AddWithValu e("@uin", Convert.ToInt32(ddluin.Sel ectedItem. Text.Trim( )));
cmd.Parameters.AddWithValu e("@sno", txtsno.Value);
cmd.Parameters.AddWithValu e("@patien t", txtpatient.Text.Trim());
cmd.Parameters.AddWithValu e("@hof", txthof.Text.Trim());
cmd.ExecuteNonQuery();
Response.Write("<script>al ert('Recor d 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#
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.StoredProcedur
cmd.Connection = con;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.ExecuteNonQuery();
Response.Write("<script>al
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER