My initial goal is to achieve followings 1. Render dynamic TextBox in custom editor webpart 2. Manage Text (, visibility, height, width etc) of the TextBox from editor part. 3. We can consider Sharepoint webpart or asp.net webpart framework
I have tried following way ( with asp.net webpart framework) but can not achieve initial goal.
private string _text;
[WebBrowsable(false)]
[Personalizable(PersonalizationScope.Shared)]
public string Text
{
get { return _text; }
set { _text = value; }
}
protected override void CreateChildControls()
{
TextBox txt = new TextBox();
txt.Text = Text;
Controls.Add(txt);
}
private TextBox txtExample;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
txtExample= new TextBox();
}
protected override void CreateChildControls()
{
Controls.Add(txtExample);
}
public override bool ApplyChanges()
{
EnsureChildControls();
CustomWebPart part = WebPartToEdit as CustomWebPart;
if (part != null)
{
part.SqlQuery = txtExample.Text;
}
}
public override void SyncChanges()
{
EnsureChildControls();
CustomWebPart part = WebPartToEdit as CustomWebPart;
if (part != null)
{
txtExample.Text = part.SqlQuery;
}
}
Problem is very clear and normal:
After changing text from editor webpart once I click on OK or Apply button system first fire CreateChildControls() event of CustomWebpart.cs before firing ApplyChanges() even before firing CreateChildControls() of CustomEditor.cs , as a result Textbox of the webpart can not update on time.
So, how can we render asp.net server side controls in webpart and manage( changing text, visibility, width, height, etc) from editor part. ?
Have any idea?