Introduction
In my projects i need validate many information like valid date, item selected...etc. to don´t create some if and else in code i created a simple class to validate this objects. I send objects, message error to return and the validation type. After process the class return a arraylist with messages error case this object don´t is true.
The class can to be modified to change color object, change text color or other client information.
How To Use The Code
I send a project with code how to use this class.
1 - Create new instance of the class
CheckObjects oCheckObjects = new CheckObjects();
2 - Add Object for Analyze
oCheckObjects.AddObjectForAnalyze(Object,MessageError, TypaValidation);
3 - Call Method To Analyze And Add To ArrayList The return.
oArrayList = oCheckObjects.ProcessAnalyze();
4 - Show Message Error
if (oArrayList.Count > 0)
{
foreach (String aString in oArrayList)
{
vErrorMensage += " - " + aString + "<A href="file: }
ClientScript.RegisterClientScriptBlock(Page.GetType(), "Error", "<script>function MessageError(){\n alert(\"Check Objects below:\\n " + vErrorMensage + "\");\n}</script>");
Body.Attributes.Add("onload", "MessageError()");
return;
}