1.11M Members

Exception Message in C#.net web site

 
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

 
0
 

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

 
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

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

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

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

 
0
 

still yhe same problem

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article