1,105,384 Community Members

Exception Message in C#.net web site

Member Avatar
umair.sabri
Light Poster
30 posts since May 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
MARKAND911
Junior Poster
148 posts since Nov 2008
Reputation Points: -1 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
JamesLogan
Newbie Poster
10 posts since May 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Rajmendra
Newbie Poster
3 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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); 
        }
Member Avatar
Rajmendra
Newbie Poster
3 posts since Nov 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
umair.sabri
Light Poster
30 posts since May 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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);
dnanetwork
Practically a Master Poster
633 posts since May 2008
Reputation Points: 18 [?]
Q&As Helped to Solve: 106 [?]
Skill Endorsements: 1 [?]
Banned
 
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

Member Avatar
umair.sabri
Light Poster
30 posts since May 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

still yhe same problem

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article