locked
Error message on Client Side RRS feed

  • Question

  • User-1499457942 posted

    Hi

     I have below code and it want that exception should appear in Dialog Box on client side

    catch (Exception ex)
    {
    throw new Exception(ex.Message);

    }

    Thanks

    Thursday, September 13, 2018 4:36 PM

All replies

  • User1120430333 posted

    You should be using global exception handling on the client side, log the error to a log file and show a user friendly error page on a redirect. You never show the user the exception message., ever.

    Thursday, September 13, 2018 6:45 PM
  • User475983607 posted

    Hi

     I have below code and it want that exception should appear in Dialog Box on client side

    catch (Exception ex)
    {
    throw new Exception(ex.Message);

    }

    Thanks

    Confused... you've already built these alerts in your other threads...  Perhaps review your code.

    Thursday, September 13, 2018 6:51 PM
  • User61956409 posted

    Hi JagjitSingh,

    want that exception should appear in Dialog Box on client side

    You can refer to the following sample to achieve your requirement.

    try
    {
        DateTime dt = Convert.ToDateTime("11111");
    }
    catch (Exception ex)
    {
        var script = "alert('" + ex.Message + "')";
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "showmes", script, true);
    }

    Following alert box will be displayed on client side:

    With Regards,

    Fei Han

    Wednesday, October 3, 2018 7:52 AM