I have created a custom field type that is using an ASCX to control what options are available for editing when viewed in the column settings. For some reason when I create this column, none of my custom values are saved. I was able to get a simpler version working using the PropertySchema
settings in the FieldTypes xml file, but as soon as I switched to using an ASCX it stopped saving. Below is how I am attempting to do this, can anyone see what I am doing wrong?
Code behind for my MaskedInputFieldEditor.ascx.cs which is rendered correctly, appears to be trying to save, but does not retain any values entered when re-opened:
public partial class MaskedInputFieldEditor : UserControl, IFieldEditor
{
protected void Page_Load(object sender, EventArgs e)
{
}
public bool DisplayAsNewSection
{
get {return false;}
}
public void OnSaveChange(SPField field, bool bNewField)
{
MaskedInput customTypedField = (MaskedInput) field;
customTypedField.Mask = tb_CustomMask.Text;
}
public void InitializeWithField(SPField field)
{
if (!Page.IsPostBack)
{
MaskedInput customTypedField = (MaskedInput)field;
tb_CustomMask.Text = customTypedField.Mask;
}
}
}
When I step through the OnSaveChange
code, everything has the appropriate values. Once it leaves the page and I go in to change the column settings all of the values I had entered (and that appeared to save) before, are empty in InitializeWithField
. Can anyone see what I am doing wrong here?