Start New Discussion within our Web Development Community

i m developing website in C#.net but my exception message is not displaying in alert box how can i disply my exception in text box in try catch any body pls tell me

Try this one....

//
// Your code
//

try
{
// place your code which may get error.
}
catch(exception ex)
{

YourTextBoxName.Text = ex.message().tostring();
or
YourLabelName.Text = ex.message().tostring();

}

place the validation code in try block only.
dont place other than this.
it wont give you where exactly you will get the error.

Any doubts ask me...
Thanks

// Rajmendra
//Asp.net Web Developer
//India

try
        {

            //Your Code goes here
          
        }
        catch(Exception ex) 
        {
            Please do right Below Line another your Code will not work//
            string strm = ex.Message.Replace('\'',' ');
            string str = "<script language='javascript'>";
            str += "alert('"+strm+"')";
            str += "</script>";
            ClientScript.RegisterStartupScript(typeof(Page), "showmessage", str); 
        }

i m developing website in C#.net but my exception message is not displaying in alert box how can i disply my exception in alertbox in try catch any body pls tell me i have tried all of these but n0 result...................

ScriptManager.RegisterStartupScript(this, typeof(Page), "test", "alert('Error - TRANSACTION ROLLED BACK'," + ex.Message + ");", true);


ClientScript.RegisterClientScriptBlock(typeof(Page), "test", "<script>alert('Error - TRANSACTION ROLLED BACK" + ex.Message + "')</script>;");



Response.Write("<script>alert('Error - TRANSACTION ROLLED BACK')</script>" + ex.Message);
try
        {
            int i = 0;
            int j = 1;
            int k = j / i;
            
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + ex.Message.ToString() + "');", true);
        }

hope that helps

This article has been dead for over six months. Start a new discussion instead.