Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling Validation when leaving controls in web form
Message
De
13/09/2010 19:03:06
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
13/09/2010 16:53:36
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01479579
Message ID:
01481058
Vues:
47
I was not able to duplicate the same error as you have. If it was me, I would just do this check without using the rules object for now because it isn't a validation for save anyway. I will look at it further when I get a chance and let you know if I find anything.
Tim

>Tim,
>
>did you have a go at duplicating this?
>
>>I just copied your code and I am going to test this in my application to see what is happening.
>>Tim
>>
>>>
>>>I've tried it like this, but I still get the same error :(
>>>
>>>Here's my actual code:
>>>
>>>in my PolicyRider.Partial.cs:
>>>
>>>
        public string ValidateSumAssuredMaxMin(Guid? planPK, decimal? sumAssured)
>>>        {
>>>            // Get the Plan for the specified PlanPK
>>>            Plan oPlan = new Plan();
>>>            oPlan.GetPlanByPlanPK((Guid)planPK);
>>>
>>>            // Call the validate method in the Rules object
>>>            return this.Rules.ValidateSumAssuredMaxMin(sumAssured, oPlan.Entity.MinSumAssured, oPlan.Entity.MaxSumAssured);
>>>
>>>        }
>>>
>>>In my PolicyRiderRules.Partial.cs:
>>>
>>>
        public string ValidateSumAssuredMaxMin(Decimal? sumAssured, Decimal? min, Decimal? max)
>>>        {
>>>            string message = null;
>>>            // check that the sum assured meets the min and max sum assured requirements
>>>            if (min > (Decimal)sumAssured
>>>                    || max < (Decimal)sumAssured)
>>>            {
>>>                message = "Rider Sum Assured must be between " + min.ToString() + " and " + max.ToString();
>>>                this.AddErrorProviderBrokenRule("SumAssured", message);
>>>            }
>>>            return message;
>>>        }
>>>
>>>In my PolicyEdit.aspx.cs:
>>>
>>>
        protected void txtRiderSumAssured_TextChanged(object sender, EventArgs e)
>>>        {
>>>            TextBox thisTextBox = (TextBox)sender;
>>>            this.oPolicyRider.Rules.ClearAll();
>>>            GridViewRow gvr = (GridViewRow)thisTextBox.Parent.Parent;
>>>            if (this.oPolicyRider.ValidateSumAssuredMaxMin((Guid)this.oPolicyRider.DataSet.Tables[0].Rows[gvr.RowIndex]["RiderFK"], decimal.Parse(thisTextBox.Text)) != null)
>>>            {
>>>                // show the message somehow
>>>            }
>>>
>>>            this.CalculateRiderPremium(true, gvr);
>>>            this.SetFocus(gvr.Cells[3].Controls[1]);
>>>        }
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform