|
Hi,
Why I am getting the above error with this code?
protected void btnSend_Click(object sender, EventArgs e)
{
if (txtMessage.Text == "")
{
Session["message_title"] = "Error";
Session["message_title_Color"] = Color.Red.ToArgb();
Session["message_text"] = "Please enter your message.";
Session["message_button_title"] = "Back";
Session["message_button_url"] = Request.UrlReferrer.ToString();
}
create_support_ticket create_support_ticket = new create_support_ticket();
create_support_ticket.add_support_ticket(txtSubject.Text, txtEmailAddress.Text, txtMessage.XHTML);
}
and this is the add_support_ticket:
public void add_support_ticket(string support_incident_title, string email_address, string support_ticket_description)
{
support_sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
support_sql_connection.Open();
support_sql_command = new MySqlCommand("sp_add_support_ticket", support_sql_connection);
support_sql_command.CommandType = CommandType.StoredProcedure;
support_sql_command.Parameters.Add("param_support_incident_title", MySqlDbType.VarChar).Value = support_incident_title;
support_sql_command.Parameters.Add("param_email_address", MySqlDbType.VarChar).Value = email_address;
support_sql_command.Parameters.Add("param_support_ticket_description", MySqlDbType.Text).Value = support_ticket_description;
int result_rows = support_sql_command.ExecuteNonQuery();
support_sql_command.Dispose();
support_sql_connection.Close();
HttpContext.Current.Session["message_title"] = "Thank you";
HttpContext.Current.Session["message_title_Color"] = Color.Blue.ToArgb();
HttpContext.Current.Session["message_text"] = "We have recieved your feedback and we will get back to you as soon as possible.";
HttpContext.Current.Session["message_button_title"] = "Back";
HttpContext.Current.Session["message_button_url"] = "Home.aspx";
HttpContext.Current.Response.Redirect("Message.aspx");
}
|
|
|
|
|
The current page is probably message.aspx, so since the page is doing a postback, your redirecting the page to itself, but it's already going there. It doesn't need to be redirected.
If didn't know you can store a color in a session buffer. I thought session buffers were reserved for primitive types.
Why not just convert the sub to a function and return a integer value of 2, 1 or 0.
0 = success
1 = error
2 = total failure
exitCode integer = addSupportTicket();
switch exitCode {
}
|
|
|
|