java sript in code behind C#
-
Im tying to write an exception message using javascript in code behind, using catch (Exception ex) { string err = ex.Message; string script = "alert('" + err + "');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Msg", script, true); } But sometimes the message doesnt get dislayed and the whole application freezes, i have noticed that its caused by the content of ex.Message eg "Unable to cast object of type 'System.DBNull' to type 'System.String'." - gives a problem. The easiest thing to do is to replace the ' signs and it works fine, but this is applies to this error message only, is there a generic solution for this problem. Thank you.
-
Im tying to write an exception message using javascript in code behind, using catch (Exception ex) { string err = ex.Message; string script = "alert('" + err + "');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Msg", script, true); } But sometimes the message doesnt get dislayed and the whole application freezes, i have noticed that its caused by the content of ex.Message eg "Unable to cast object of type 'System.DBNull' to type 'System.String'." - gives a problem. The easiest thing to do is to replace the ' signs and it works fine, but this is applies to this error message only, is there a generic solution for this problem. Thank you.
-
Im tying to write an exception message using javascript in code behind, using catch (Exception ex) { string err = ex.Message; string script = "alert('" + err + "');"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Msg", script, true); } But sometimes the message doesnt get dislayed and the whole application freezes, i have noticed that its caused by the content of ex.Message eg "Unable to cast object of type 'System.DBNull' to type 'System.String'." - gives a problem. The easiest thing to do is to replace the ' signs and it works fine, but this is applies to this error message only, is there a generic solution for this problem. Thank you.
-
Thank you for your response, but there is no output from response; i just took it as you wrote it, maybe its the synhax for response i will chaeck that and will come back to u. Thank u.