My initial goal is to achieve the following
Render dynamic TextBox in custom editor webpart
Manage Text (, visibility, height, width etc) of the TextBox from editor part.
We can consider Sharepoint webpart or asp.net webpart framework
I have tried following way ( with asp.net webpart framework) but I can not achieve the initial goal.
//CustomWebPart.cs
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);
}
//CustomEditor.cs
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:
After changing the text from editor webpart, once I click on OK or Apply button the system first triggers the CreateChildControls() event for CustomWebpart.cs before firing ApplyChanges(), even before firing CreateChildControls() for 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. ?
Please help.
