When I am refreshing my page in chrome browser it gives me error as "Form Resubmission".I've used Response.Redirect as well after close my connection but it gives me same error and along with that it doesn't shows Label message follwing are my c# code Please help me.
public partial class admin_Upload : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CBMIAConnectionString"].ConnectionString);
SqlDataReader dr = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Dropdown();
}
}
protected void Lnk_Minutes_Click(object sender, EventArgs e)
{
if (File_Agenda.HasFile && File_Minutes.HasFile && File_Attendance.HasFile)
{
SqlCommand cmd = null;
string Date = Txt_Date.Text;
string fname = File_Agenda.PostedFile.FileName;
string ffname = File_Minutes.PostedFile.FileName;
string attendance = File_Attendance.PostedFile.FileName;
string Extension = Path.GetExtension(fname);
string Extensionn = Path.GetExtension(fname);
int flag = 0;
switch (Extension.ToLower())
{
case ".doc":
case ".docx":
case ".pdf":
flag = 1;
break;
default:
flag = 0;
break;
}
if (flag == 1)
{
File_Agenda.SaveAs(Server.MapPath("http://localhost:33213/cbmi/Download_Meeting_Files/Agenda_Files/" + fname));
File_Minutes.SaveAs(Server.MapPath("~/Download_Meeting_Files/Minutes_Files/" + ffname));
File_Attendance.SaveAs(Server.MapPath("~/Download_Meeting_Files/Attendance_Files/" + attendance));
cmd = new SqlCommand("Insert into Upload_Age_Min (Date,Agenda,Minutes,Attendance) values(@date,@aggenda ,@minutess,@attendancee)", con);
cmd.Parameters.Add("@date", SqlDbType.NVarChar).Value = Date;
cmd.Parameters.AddWithValue("@aggenda", fname);
cmd.Parameters.AddWithValue("@minutess", ffname);
cmd.Parameters.AddWithValue("@attendancee", attendance);
con.Open();
if (cmd.ExecuteNonQuery() != 0)
{
Label1.Text = "File Uploaded Successfully";
Label1.ForeColor = System.Drawing.Color.Green;
Txt_Date.Text = "";
con.Close();
//Response.Redirect(Request.Url.AbsoluteUri);
}
else
{
Label1.Text = "File failed to Upload";
}
}
else
{
Label1.Text = "Only .doc,.docx and .pdf file is Allowed";
}
}
else
{
Label1.Text = "Select The File";
}
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
string upload = ddl_Upload.SelectedValue;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = ("delete from Upload_Age_Min where Date = @upload");
cmd.Parameters.Add("@upload", SqlDbType.NVarChar).Value = upload;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Lbl_Delete.Text = "Group deleted successfully!";
ddl_Upload.ClearSelection();
}
private void Dropdown()
{
string constr = ConfigurationManager.ConnectionStrings["CBMIAConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT Date FROM Upload_Age_Min"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
ddl_Upload.DataSource = cmd.ExecuteReader();
ddl_Upload.DataTextField = "Date";
ddl_Upload.DataValueField = "Date";
ddl_Upload.DataBind();
con.Close();
}
}
ddl_Upload.Items.Insert(0, new ListItem("Select Date", "0"));
}
}
I am inserting and deleting some details from this page but after inserting details when I am refreshing the page to delete record it gives me error like "confirm form resubmission". for this error i used reponse.redirect but its not working and after applying response.redirect label msg doesn't shows as well.
what I need to do so that i can refresh my page after inserting or deleting record.