How to show catch block exception message in a alert message box using c#.net language?
is it possible to write solution in catch block? how to write?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Aug 1, 2013, 2:14 AM EDT
catch (Exception e)
{
MessageBox.Show(e.Message);
}
ranjan sahooRank #5,709 · 289 reputationPosted Aug 1, 2013, 9:07 PM EDT
in web application
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 9:16 PM EDT
I suggest not to display the exception message thru javascript, instead show it by using Label.
You can do using script like this
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 1, 2013, 9:22 PM EDT
catch (Exception ex)
{
Response.Write("");
}
Mahesh5 reputationPosted Aug 1, 2013, 10:49 PM EDT
try this in your code behind
ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('"+ex.Message.ToString()+"');",true);
and write the following javascript function in aspx
function Showalert() {
alert('Call JavaScript function from codebehind');
}