I want to show the excetion in message box in asp.Net webpage

Last post 08-30-2007 6:03 AM by Mikesdotnetting. 1 replies.

Sort Posts:

  • I want to show the excetion in message box in asp.Net webpage

    08-30-2007, 1:27 AM
    • Loading...
    • vvpnkapil
    • Joined on 07-25-2007, 9:39 AM
    • Posts 9

    try

    {

    string str = "insert into employee(empid,empname,empgrade,empdept,empsal) values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "'," + TextBox4.Text + "," + TextBox5.Text + ")";SqlCommand cmd = new SqlCommand(str, cn);

    cn.Open();

    cmd.ExecuteNonQuery();

    }

    catch (Exception ee)

    {

    Response.Write(ee.Message);

    }

     I tried it using javascript but Iam getting the message What I wrote ,but I want  to get the returned exception.

    could any body help me out from this ..

    regards

    kapil.....................

     

     

  • Re: I want to show the excetion in message box in asp.Net webpage

    08-30-2007, 6:03 AM

    try

    {

    string str = "insert into employee(empid,empname,empgrade,empdept,empsal) values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "'," + TextBox4.Text + "," + TextBox5.Text + ")";SqlCommand cmd = new SqlCommand(str, cn);

    cn.Open();

    cmd.ExecuteNonQuery();

    }

    catch (Exception ee)

    { 

            Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "alert('" + ee.Message + "');", true);

    }

     

     

    Regards Mike
    [MVP - ASP/ASP.NET]
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter