0

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

6
Contributors
8
Replies
13
Views
7 Years
Discussion Span
Last Post by __avd
0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

0
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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.