Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling Validation when leaving controls in web form
Message
De
08/09/2010 14:38:39
 
 
À
08/09/2010 12:30:42
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01479579
Message ID:
01480596
Vues:
42
>Hi Frank,
>
>>Here's the code:
>>
>>
        public string ValidateSumAssuredMaxMin(Guid? planPK, decimal? sumAssured)
>>        {
>>            string message = null;
>>                Plan oPlan = new Plan();
>>                oPlan.GetPlanByPlanPK((Guid)planPK);
>>                // check that the sum assured meets the min and max sum assured requirements
>>                if (oPlan.Entity.MinSumAssured > (decimal)sumAssured
>>                        || oPlan.Entity.MaxSumAssured < (decimal)sumAssured)
>>                {
>>                    message = "Rider Sum Assured must be between " + oPlan.Entity.MinSumAssured.ToString() + " and " + oPlan.Entity.MaxSumAssured.ToString();
>>                    this.AddErrorProviderBrokenRule("SumAssured", message);
>>                }
>>            return message;
>>        }
>>
>>This is called from a textbox that is in a grid displaying/editing the child business object.
>
>This is a bit of an odd answer, so bear with me. The business rules object is normally accessed via the business object and in this case you are accessing the rules object this way but then in the rules object you are creating a new business object. I did not trace through this to see what happens, but I would recommend a different approach. Maybe this.
>
>Put a method in your business object that you call instead of your rules object that can begin the validation process. What that method would do is GetPlanByPlanPK and then once the record is retrieved, let that method call the rules.ValidateSumAssuredMaxMin method. I would take the code out of the validate method which creates a business object and retrieves data.
>
>I hope that made sense, and let me know how that turns out.
>Tim

Tim,

if I am doing something out of the ordinary I would prefer to do it the recommended way. So rather than trying it your suggested way, what would be the normal way to validate a field based on another field? In this case can I assume the Min and MaxSumassured are available without having to get them by creating a new BO?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform