I am creating a webform using ASP.NET and C#. I created a method that posts an error message which is picked up by the Validation Summary control.
protected void PostErrorToCusVal(ref System.Web.UI.WebControls.CustomValidator ErrorObj, string ErrHead, string ErrMsg) {
ErrorObj.ErrorMessage = "*SomeHTML/CSS*" + ErrHead + "*SomeHTML/CSS*" + ErrMsg + "*SomeHTML/CSS*";
}
I am having trouble passing anything other than a CustomValidator control to it. I want to be able to pass any validation control to it and set the ErrorMessage property. I tried using using BaseValidator and casting, but that wouldn’t work. Is it possible for this to be done?
Thanks,
Ozzy
You can alternatively write a helper method as follows which will be more generic and could be used at many places
For using it, just pass the Page, Exception, Message if any to override the exception message, and the validationgroup of the page.
Hope this helps