Property Friendly Name not coming in validation

Property Friendly Name not coming in validation

Old forum URL: forums.lhotka.net/forums/t/9900.aspx


Vinodonly posted on Sunday, December 26, 2010

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

 

 

 

JonnyBee replied on Sunday, December 26, 2010

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.

Vinodonly replied on Monday, December 27, 2010

i'm using ver 3.8.3.. .VS 2010, .net 4.0

i tried above even that is returning the same result..

 

JonnyBee replied on Monday, December 27, 2010

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

Vinodonly replied on Monday, December 27, 2010

 

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