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 20:29:20
 
 
À
07/09/2010 16:18:03
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:
01480505
Vues:
50
Hi Tim,

yes, I am aware of the repercussions of the post backs.

Neither the GridViewRow, nor the BO, nor the rules is null. The value I am passing in is valid. If the validate code is called normally during the save it works fine.

The error stops me here:

if (BusinessObject.EntityFramework || (epArgs.TableName.ToLower() == TableName.ToLower()))

in OakLeaf.MM.Main.Web.UI.mmWebDataHelper.SetControlErrorMessage

At this point in time epArgs.TableName is null.

The call stack is:

OakLeaf.MM2008.WebForms.dll!OakLeaf.MM.Main.Web.UI.mmWebDataHelper.SetControlErrorMessage(OakLeaf.MM.Main.Web.UI.ImmWebBindingDataGrid control = {OakLeaf.MM.Main.Web.UI.WebControls.mmGridView}, OakLeaf.MM.Main.Business.mmBaseBusinessObject bizObj = {SamaanSystems.IAS.Business.PolicyRider}, OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs e = {OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs}) Line 574 + 0x25 bytes C#
> OakLeaf.MM2008.WebForms.dll!OakLeaf.MM.Main.Web.UI.WebControls.mmGridView.StateChangeHandler(OakLeaf.MM.Main.Business.mmBaseBusinessObject bizObj = {SamaanSystems.IAS.Business.PolicyRider}, OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs e = {OakLeaf.MM.Main.Business.mmBusinessStateChangeEventArgs}) Line 481 + 0xf bytes C#
[External Code]
OakLeaf.MM2008.Framework.dll!OakLeaf.MM.Main.Business.mmBusinessObject.OnStateChange(OakLeaf.MM.Main.Business.mmBusinessState bizState = BrokenRulesWarnings, string tableName = null, object primaryKeyValue = {OakLeaf.MM.Main.Business.mmErrorProviderArgs}, object[] primaryKeyValues = null) Line 5849 + 0x37 bytes C#
OakLeaf.MM2008.Framework.dll!OakLeaf.MM.Main.Business.mmBusinessObject.OnErrorProviderBrokenRuleAdd(OakLeaf.MM.Main.Business.mmErrorProviderArgs arg = {OakLeaf.MM.Main.Business.mmErrorProviderArgs}) Line 4990 + 0x17 bytes C#
OakLeaf.MM2008.Framework.dll!OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(OakLeaf.MM.Main.Business.mmErrorProviderArgs arg = {OakLeaf.MM.Main.Business.mmErrorProviderArgs}) Line 217 + 0xf bytes C#
OakLeaf.MM2008.Framework.dll!OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(string propertyName = "SumAssured", string columnName = "SumAssured", string errorText = "Rider Sum Assured must be between 1000.00 and 10000000.00") Line 294 + 0xb bytes C#
OakLeaf.MM2008.Framework.dll!OakLeaf.MM.Main.Business.mmBusinessRule.AddErrorProviderBrokenRule(string columnName = "SumAssured", string errorText = "Rider Sum Assured must be between 1000.00 and 10000000.00") Line 323 + 0x14 bytes C#
SamaanSystems.IAS.Business.DLL!SamaanSystems.IAS.Business.PolicyRiderRules.ValidateSumAssuredMaxMin(System.Guid? planPK = {80655338-7c15-4905-81bc-6a93336e52ec}, decimal? sumAssured = 100) Line 39 + 0x11 bytes C#
SamaanSystems.IAS.Web.DLL!SamaanSystems.IAS.Web.PolicyEdit.txtRiderSumAssured_TextChanged(object sender = {OakLeaf.MM.Main.Web.UI.WebControls.mmTextBox}, System.EventArgs e = {System.EventArgs}) Line 1244 + 0x18a bytes C#
[External Code]



>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
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