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

Recommended Answers

All 8 Replies

let the textbox in which u have to display message be txtMessage

try
{
         // Your Code
}
catch(excetion ex)
{
        txtMessage.text=ex.message.tostring();
}

If problem solved than mark it as SOLVED.
Also visit markand-bhatt.blogspot.com

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); 
        }

just copy and past it then run Typing this can Be caues to failer of Code

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

still yhe same problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.