LoadDefaultMetaField - Null reference exception

Posted by Community Admin on 04-Aug-2018 12:30

LoadDefaultMetaField - Null reference exception

All Replies

Posted by Community Admin on 18-Nov-2011 00:00

Hi,

I'm writing my custom control and my code fails when it attempts to retrieve a default meta field.

[TypeConverter(typeof(ExpandableObjectConverter))]
public Telerik.Sitefinity.Metadata.Model.IMetaField MetaField
get
if(this._metaField == null)
this._metaField = this.LoadDefaultMetaField();
this._metaField.FieldName = "NamedTextBox_" + this.ClientID;
return this._metaField;
set this._metaField = value;


One of the problems is that I didn't find a clear explanation in SDK or on the blogs on how we should be using MetaFields. I guess that it will persist value from my custom field into the database, but that's only a guess.

Can you please give a brief explanation on how we should be using meta fields and why this.LoadDefaultMetaField throws a null reference exception?

Thank you

Posted by Community Admin on 23-Nov-2011 00:00

Hi Viktor,

Yes you are right LoadDefaultMetafield will persist the value of the form control into the database using database mapping attribute. I suppose you are getting an exception because of a missing using . I suggest adding using Telerik.Sitefinity.Model, using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields. I suppose you have already added this as described here. If you are still getting the exception can you paste some code here to see the code used?

Greetings,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed