954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Label visbiliy concept after insert button

Please help me i do not want to show successfully message in again insertation in page.

protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string constr;
            constr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);

            con.Open();
            string str = "insert   into  Doe_detail values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')";
            SqlCommand cmd = new SqlCommand(str, con);
            cmd.ExecuteNonQuery();
            con.Close();
            Label2.Visible = true;
            Label2.Text = "Data has Been Successfully inserted";
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            TextBox5.Text = "";
        }
        catch (Exception es)
        {
        }
    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        Label2.Visible = false;
    }
}
Attachments Messageproblem.docx (57.8KB)
goltu
Newbie Poster
14 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

You can do it with help of javascript. On client side "onclick" event of all Textboxes (1 to 5), call the javascript function to hide message label. Try to write the code, if there is some problem, we will help you.

sufyan2011
Junior Poster
166 posts since Dec 2011
Reputation Points: 9
Solved Threads: 20
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You