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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MaheshPosted Aug 2, 2013, 2:49 AM
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');
}
Sanjeeb LenkaPosted Aug 2, 2013, 1:22 AM
catch (Exception ex)
{
Response.Write("");
}
Iftikar HussainPosted Aug 2, 2013, 1:16 AM
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
ranjan sahooPosted Aug 2, 2013, 1:07 AM
in web application
VulpesPosted Aug 1, 2013, 6:14 AM
catch (Exception e)
{
MessageBox.Show(e.Message);
}