I created a custom visual user control webpart property for my SharePoint webpart. The property has a textbox which is getting empty after an IIS reset. Can anyone tell me how to solve this issue please. Sometimes it resets itself without IIS reset as well not 100% sure though.
EDIT
My webpart class
public class MyVisualBoard : System.Web.UI.WebControls.WebParts.WebPart
{
public const string webPartName = "MyVisualBoard";
private string _ascxPath;
public MyVisualBoard()
{
_ascxPath = @"~/_ControlTemplates/MyVisualBoard/MyVisualBoardUserControl.ascx";
}
protected override void CreateChildControls()
{
base.CreateChildControls(); //Always child controls under base childcontrols
try
{
Control userControl = Page.LoadControl(_ascxPath);
Controls.Add(userControl);
}
catch (Exception ex)
{
LogErrorMessage(ex, webPartName, Context.Request.Url.AbsoluteUri);
}
}
protected override void OnPreRender(EventArgs e)
{
try
{
base.OnPreRender(e);
}
catch (Exception ex)
{
LogErrorMessage(ex, webPartName, Context.Request.Url.AbsoluteUri);
ShowErrorMessage(String.Empty);
return;
}
}
protected override void OnInit(EventArgs e)
{
// Script manager need to be added for the update panel to work
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager sMgr = new ScriptManager();
Page.Form.Controls.AddAt(0, sMgr);
}
base.OnInit(e);
}
public static decimal MyCustomProperty;
[SPWebCategoryName("My Custom Property")]
[Personalizable(PersonalizationScope.Shared)]
[WebDisplayName("My Custom Property")]
[WebBrowsable(true)]
public decimal _MyCustomProperty
{
get { return MyCustomProperty; }
set { MyCustomProperty = value; }
}
//more custom properties are just like it (like 7 of them)
User control class looks like this,
using MyVisualBoard.WebParts.MyVisualBoard;
namespace MyVisualBoard.Webparts.MyVisualBoard
{
public partial class MyVisualBoardUserControl : UserControl
{
private const string webPartName = "MyVisualBoard";
protected void Page_Load(object sender, EventArgs e)
{
this.MyCustomProperty.Text = MyVisualBoard.MyCustomProperty;
}
//Some other methods here as well