Answer: This can be done by implementing a method called GetLastError(). Generally this returns a ASPError object stating the error condition that has occurred. This method will work only before the .ASP page sent any content to the Client.
Sample Code
Exception LastErrorOccured;
String ShowErrMessage;
LastErrorOccured = Server.GetLastError();
if (LastErrorOccured != null)
ShowErrMessage = LastErrorOccured.Message;
else
ShowErrMessage = "No Errors";
Response.Write("Last Error Occured = " + ShowErrMessage);
Asked In: Many Interviews |
Alert Moderator