Hello,
I have a string field that I always want to force to lowercase, regardless of the case that the user entered.
I have tried overriding the OnSetValue method using a partial class:
/// <summary>
/// Entity class which represents the entity 'MerchantStorePageSeoNames'.<br/><br/>
///
/// </summary>
public partial class MerchantStorePageSeoNamesEntity : CommonEntityBase, ISerializable
{
protected override void OnSetValue(int fieldIndex, object valueToSet, out bool cancel)
{
base.OnSetValue(fieldIndex, valueToSet, out cancel);
if (fieldIndex == (int)MerchantStorePageSeoNamesFieldIndex.SeoFriendlyName)
{
valueToSet = (object)valueToSet.ToString().ToLower();
this.Fields[fieldIndex].ForcedCurrentValueWrite(valueToSet);
}
}
}
When I set the entity field, ie. entityVar.SeoFriendlyName = "LLBLRocks"; , the code enters this overridden method. The value of the SeoFriendlyName property at the end of the procedure is correct, "llblrocks", but once it exits to the calling procedure, it is upper case again.
Does anyone have any suggestions on how to achieve this within the entity itself?
Thanks.
Can1