0

I have a try and catch block for sending multiple emails. Everytime a exception in email address occurs then in Catch block it is set as text to multiline textbox. But I am having problem showing large data.

the current code is:

catch(Exception ex)
{
   txtexception.Text = txtexception.Text + "\n" + ex.Message;                   
}

Note: I am testing it on data having 5 incorrect email addresses. So there are 5 exception messages to display.

So, I am now thinking of displaying error messages in validation summary control. Is there any way to do that from code behind(button click).

Thank you for all your help!

Preet
  • 984
  • 2
  • 14
  • 34
  • Use a `CustomValidator` to set custom error message from `catch` block. You can create custom validator in markup, or add it dynamically. – Tetsuya Yamamoto May 24 '18 at 03:48
  • Thank you for the idea, will search for that! If you can provide link to any example that would be great! thanks again – Preet May 24 '18 at 03:50
  • You can see examples [here](https://stackoverflow.com/questions/777889/on-postback-how-can-i-add-a-error-message-to-validation-summary). The implementation depends on which event that `catch` block belongs to. – Tetsuya Yamamoto May 24 '18 at 03:54
  • ok will look, Thanks – Preet May 24 '18 at 03:55

0 Answers0