Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling Validation when leaving controls in web form
Message
De
07/09/2010 16:18:03
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
07/09/2010 15:22:45
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01479579
Message ID:
01480468
Vues:
46
Hi Frank,

Yes, I am back but not up to full speed yet. With a web application, I assume you realize how the performance could be affected by the post backs for validation on each control. That said, could you tell what object was null? If you step through that code, is the GridViewRow null? Or the business object or the rules? Also is the value you are passing into the ValidateSumAssuredMaxMin() method valid?

I am suspect the rules method may be trying to access something that is null such as the current Entity. Can you set a break point in the method and step through so you know exactly what is null?
Tim

>>
>>Tim
>
>Hi Tim,
>
>are you back from your vacation?
>
>Yes, I want to validate certain fields/controls as the user enters data in them.
>
>I have tried this:
>
>
        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.Rules.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]);
>        }
>
>but I get an error:
>
>
Server Error in '/' Application.
>Object reference not set to an instance of an object. 
>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
>
>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
>
>Source Error: 
>
>Line 37:                 {
>Line 38:                     message = "Rider Sum Assured must be between " + oPlan.Entity.MinSumAssured.ToString() + " and " + oPlan.Entity.MaxSumAssured.ToString();
>Line 39:                     this.AddErrorProviderBrokenRule("SumAssured", message);
>Line 40:                 }
>Line 41:             return message;
>
>
>Source File: C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Business\PolicyRider\PolicyRiderRules.Partial.cs    Line: 39 
>
>Stack Trace: 
>
>[NullReferenceException: Object reference not set to an instance of an object.]
>   OakLeaf.MM.Main.Web.UI.mmWebDataHelper.SetControlErrorMessage(ImmWebBindingDataGrid control, mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +273
>   OakLeaf.MM.Main.Web.UI.WebControls.mmGridView.StateChangeHandler(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +211
>   OakLeaf.MM.Main.Business.mmBusinessStateChangeDelegate.Invoke(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e) +0
>   OakLeaf.MM.Main.Business.mmBusinessObject.OnStateChange(mmBusinessState bizState, String tableName, Object primaryKeyValue, Object[] primaryKeyValues) +174
>   OakLeaf.MM.Main.Business.mmBusinessObject.OnErrorProviderBrokenRuleAdd(mmErrorProviderArgs arg) +111
>   OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(mmErrorProviderArgs arg) +768
>   OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(String propertyName, String columnName, String errorText) +434
>   OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(String columnName, String errorText) +46
>   SamaanSystems.IAS.Business.PolicyRiderRules.ValidateSumAssuredMaxMin(Nullable`1 planPK, Nullable`1 sumAssured) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Business\PolicyRider\PolicyRiderRules.Partial.cs:39
>   SamaanSystems.IAS.Web.PolicyEdit.txtRiderSumAssured_TextChanged(Object sender, EventArgs e) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Web\PolicyEdit.aspx.cs:1244
>   System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e) +8739502
>   System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent() +55
>   System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +10
>   System.Web.UI.Page.RaiseChangedEvents() +165
>   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
>
>
>Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3614
>
>Although VS debugger stops on this line:
>
>if (BusinessObject.EntityFramework || (epArgs.TableName.ToLower() == TableName.ToLower()))
>
>in OakLeaf.MM.Main.Web.UI.mmWebDataHelper.SetControlErrorMessage
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform