Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 
 //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 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?
Posted 22-Sep-12 9:58am
Edited 22-Sep-12 16:49pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 205
1 Sergey Alexandrovich Kryukov 165
2 jlopez788 109
3 Rob Philpott 100
4 Prakriti Goyal 97
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,589
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100