Sir once the user clicks tje button he is redicected to logout.aspx page
on the page_load of this page(logout.aspx) i am terminating the session using Session.Abandon();
when the user clicks back button of the browser as the sesssion is abandon i want to show the alert message and then redirect to other page.
instead of above it allowing the user to again redirect to logout.aspx page.(the operations are not reflecting on the database when he clicks back and tries to select the radio button).
below is my code
please tel the necessary changes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class wardno171 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
if (Session["name"] == null && Session["pass"] == null)
{
string script = "window.onload = function() { alert('Session Terminated! Please login again'); window.location = 'signin.aspx'; }";
ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true);
// Response.Redirect("signin.aspx");
}
else
{
Label1.Text = Request.QueryString["ab"].ToString();
Label2.Text = "WELCOME " + Session["name"].ToString().ToUpper();
}
}
protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
{
if (RadioButton1.Checked)
{
string z = "Voted";
SqlCommand cmd1 = new SqlCommand("UPDATE [ward171] SET [Votes] = [Votes] + 1 WHERE [Candidate] =" + "'Sadanand Surve'", con);
cmd1.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("UPDATE [users] SET [Status] ='" + z + "' WHERE [ElectionId] =" + "'" + Label1.Text + "'", con);
cmd2.ExecuteNonQuery();
con.Close();
Response.Redirect("logout.aspx");
}
else if (RadioButton2.Checked)
{
string z = "Voted";
SqlCommand cmd1 = new SqlCommand("UPDATE [ward171] SET [Votes] = [Votes] + 1 WHERE [Candidate] =" + "'Kumud Patil'", con);
cmd1.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("UPDATE [users] SET [Status] ='" + z + "' WHERE [ElectionId] =" + "'" + Label1.Text + "'", con);
cmd2.ExecuteNonQuery();
con.Close();
Response.Redirect("logout.aspx");
}
else
{
string message = "Please select a choice";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}
}
}