Click here to Skip to main content
11,484,402 members (65,158 online)
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 10:58am
Edited 22-Sep-12 17: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 Maciej Los 190
1 Sergey Alexandrovich Kryukov 170
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2015
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