i'm declaring props in following way (friendly name is also given)
protected static PropertyInfo<int> ProdUnitIDProp = RegisterProperty<int>(o => o.ProdUnitID, "Prod Unit");
But in my custom validation method when i'm trying to access it via below property then it is null, is this a bug or am i missing something ?
e.PropertyFriendlyName
Which version of csla are you using?
Try this:
protected static PropertyInfo<int> ProdUnitIDProp = RegisterProperty<int>(o => o.ProdUnitID, "Prod Unit", string.Empty);
Maybe the RegisterProperty is confused by 2 similar overloads (only for properties of type string) and takes "Prod unit" as the default value in your declaration.
i'm using ver 3.8.3.. .VS 2010, .net 4.0
i tried above even that is returning the same result..
Ok, so the PropertyInfo object itself is OK.
How do you add the rule to the property in AddBusinessRules?
Is the PropertyInfo object sent as parameter to new RuleArgs or do you use the old syntax of propety name as a string?
You must also register rules using the PropertyInfo object in order to get the value to e.FriendlyPropertyName.
Ex:
ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired, new Csla.Validation.RuleArgs(NameProperty));
ok, i'm using it as below which is what is creating problem.. i just changed as per your suggestion and now it is working. Thansk for your help. ValidationRules.AddRule(
CommonRules.ValueRequired, "ProdUnitID");
Copyright (c) Marimer LLC