I have used the below C# code in SharePoint 2010 webpart to get hold of my configuration settings,
string _configInfo;
[Personalizable(PersonalizationScope.Shared), WebBrowsable(false)]
public string ConfigInfo
{
get
{
return this._configInfo;
}
set
{
this._configInfo = value;
}
}
private HiddenField sourceListConfig;
protected override void CreateChildControls()
{
this.sourceListConfig = new HiddenField();
sourceListConfig.ID = "SourceListConfigID";
sourceListConfig.Value = this.ConfigInfo;
this.sourceListConfig.ValueChanged += new EventHandler(sourceListConfig_ValueChanged);
this.Controls.Add(sourceListConfig);
base.CreateChildControls();
}
void sourceListConfig_ValueChanged(object sender, EventArgs e)
{
this.ConfigInfo = this.sourceListConfig.Value;
this.SetPersonalizationDirty();
}
Server side coding is restricted on latest versions of SharePoint. So, how do i implement this for my webpart in latest versions of SharePoint like 2013/2016.
There is a "Properties" in webpart's "Elements.xml" that we can use in webpart configurations. But, i have a lot of controls to get hold of it's value. So, i can't use that. Instead i have used a long string that holds the value of webpart controls. For example, i have 10 checkboxes and i will hold those values in that string and also update when it gets changed. I just used the checkboxes just for understanding and also i am using more than 50 controls in my webpart.
What is the recommended option in latest versions of SharePoint?