Dynamically Create/Update Cute Editor at run time

Last post 01-25-2012, 1:10 PM by qsun. 11 replies.
Sort Posts: Previous Next
  •  10-10-2005, 11:16 PM 11608

    Dynamically Create/Update Cute Editor at run time

    Hi,

    I want to create the editor dynamically at run time and I have done that. My problem is I can't get/update the content/text from the editor when I created dynamically.  With the standart textbox in VS.NET 2003 I use: request.form(id) to get its value but apparently this doesn't apply to Cute editor.   I also tried page.findcontrol(id) but to no avail.

    The reason I don't want to use the datagrid example is because I have to dynamically create other different controls as well not simply just Cute Editor.

    =========================================================================

    for i as integer = 0 to 5
       Dim tr As New HtmlTableRow

       Dim td As New HtmlTableCell
       Dim ce As New CuteEditor.Editor
       
       ce.ID = i 
       ce.AutoConfigure = CuteEditor.AutoConfigure.Minimal
       ce.Height = Unit.Pixel(200)
       ce.Width = Unit.Pixel(300) 
       
       td.Controls.Add(ce) 
       tr.Cells.Add(td)

        table.rows.insert(i,tr)
    next
     
    ==========================================================================
     
    Any ideas of how to get the content from the editor?
     
    Thanks
     
  •  10-11-2005, 3:36 PM 11645 in reply to 11608

    Re: Dynamically Create/Update Cute Editor at run time

  •  10-11-2005, 4:15 PM 11646 in reply to 11608

    Re: Dynamically Create/Update Cute Editor at run time

     
    Source code:
     
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor"%>
    <%@ Page Language="C#" ValidateRequest="False"%>
       <body>
      <form runat="server">
       <h4>How many Editors would you like to create? (<i>Please choose vaule between 1 and 10</i>)</h4>
       <hr>
       <asp:textbox runat="Server" id="txtTBCount" Columns="3" />
       <asp:RangeValidator runat="server" ControlToValidate="txtTBCount"
         MinimumValue="1" MaximumValue="10" Type="Integer"
         ErrorMessage="Make sure that you choose a value between 1 and 10!" ID="Rangevalidator1" NAME="Rangevalidator1"/>
       <br />
       <asp:button runat="server" Text="Create Dynamic Editors" OnClick="CreateEditors" ID="Button1" NAME="Button1"/>
       <p>
        <asp:PlaceHolder runat="server" id="EditorsHere" />
       </p>
      </form>
      <script runat="server">
      
       int count = 1;
         
       void IterateThroughChildren(Control parent)
       {
        foreach (Control c in parent.Controls)
        {
         if (c.GetType().ToString().Equals("CuteEditor.Editor") &&
          c.ID == null)
         {
         ((CuteEditor.Editor) c).Text = "Editor " + count.ToString();
         ((CuteEditor.Editor) c).AutoConfigure  = AutoConfigure.Simple;
         ((CuteEditor.Editor) c).Height  = 200;    
         ((CuteEditor.Editor) c).ThemeType  = ThemeType.Office2003_BlueTheme;
         
         count++;
         }
              
         if (c.Controls.Count > 0)
         {         
          IterateThroughChildren(c);         
         }
        }
       }
       void CreateEditors(Object sender, EventArgs e)
       {
        if (!Page.IsValid) return;
            
        int n = Int32.Parse(txtTBCount.Text);
            
        // now, create n Editors, adding them to the PlaceHolder EditorsHere
        for (int i = 0; i < n; i++)
        {
         EditorsHere.Controls.Add(new CuteEditor.Editor());
        }
            
        // now, set the Text property of each CuteEditor.Editor
        IterateThroughChildren(this);
       }
      </script>
     </body>
    </HTML>

    Hope it helps.

    Let me know if you have any further questions.



    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-11-2005, 7:30 PM 11656 in reply to 11646

    Re: Dynamically Create/Update Cute Editor at run time

    Hi Adam,
     
    thanks for the post, unfortunately it wasn't the answer i'm looking for. Please refer to my previous post.

    My question was how do you SAVE the content in cute editor - how do you find the cute editor object when dynamically generated and save its content
      
    Thanks
     
  •  10-11-2005, 7:49 PM 11657 in reply to 11646

    Re: Dynamically Create/Update Cute Editor at run time

    >>My question was how do you SAVE the content in cute editor - how do you find the cute editor object when dynamically generated and save its content


    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor"%>
    <%@ Page Language="C#" ValidateRequest="False"%>
       <body>
      <form runat="server">
       <h4>How many Editors would you like to create? (<i>Please choose vaule between 1 and 10</i>)</h4>
       <hr>
       <asp:textbox runat="Server" id="txtTBCount" Columns="3" />
       <asp:RangeValidator runat="server" ControlToValidate="txtTBCount"
         MinimumValue="1" MaximumValue="10" Type="Integer"
         ErrorMessage="Make sure that you choose a value between 1 and 10!" ID="Rangevalidator1" NAME="Rangevalidator1"/>
       <br />
       <asp:button runat="server" Text="Create Dynamic Editors" OnClick="CreateEditors" ID="Button1" NAME="Button1"/>
       <p>
        <asp:PlaceHolder runat="server" id="EditorsHere" />
       </p>
      </form>
      <script runat="server">
      
       int count = 1;
          
        //Please modify the following code to meet your requirements:
     
      void IterateThroughChildren(Control parent)
       {
        foreach (Control c in parent.Controls)
        {
         if (c.GetType().ToString().Equals("CuteEditor.Editor") &&
          c.ID == null)
         {
         ((CuteEditor.Editor) c).Text = "Editor " + count.ToString();
         ((CuteEditor.Editor) c).AutoConfigure  = AutoConfigure.Simple;
         ((CuteEditor.Editor) c).Height  = 200;    
         ((CuteEditor.Editor) c).ThemeType  = ThemeType.Office2003_BlueTheme;
         
         count++;
         }
              
         if (c.Controls.Count > 0)
         {         
          IterateThroughChildren(c);         
         }
        }
       }


       void CreateEditors(Object sender, EventArgs e)
       {
        if (!Page.IsValid) return;
            
        int n = Int32.Parse(txtTBCount.Text);
            
        // now, create n Editors, adding them to the PlaceHolder EditorsHere
        for (int i = 0; i < n; i++)
        {
         EditorsHere.Controls.Add(new CuteEditor.Editor());
        }
            
        // now, set the Text property of each CuteEditor.Editor
        IterateThroughChildren(this);
       }
      </script>
     </body>
    </HTML>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-12-2005, 7:14 PM 11686 in reply to 11657

    Re: Dynamically Create/Update Cute Editor at run time

     You misunderstood me again. my problem is not populating the controls at run time but how to find the controls and the content e.g "hello there" when click update. Thanks

  •  10-16-2005, 7:02 PM 11760 in reply to 11686

    Re: Dynamically Create/Update Cute Editor at run time

    can anyone please help. Thanks
  •  10-17-2005, 7:31 PM 11776 in reply to 11760

    Re: Dynamically Create/Update Cute Editor at run time

    hdn,

    Can you post the code showing how to create the controls?

    Then I will figure out how to find those controls.
     
    Right now the only option is doing a loop:
     
      foreach (Control c in parent.Controls)
        {
         if (c.GetType().ToString().Equals("CuteEditor.Editor") &&
          c.ID == null)
         {
         ((CuteEditor.Editor) c).Text = "Editor " + count.ToString();
         ((CuteEditor.Editor) c).AutoConfigure  = AutoConfigure.Simple;
         ((CuteEditor.Editor) c).Height  = 200;    
         ((CuteEditor.Editor) c).ThemeType  = ThemeType.Office2003_BlueTheme;
         
         count++;
         }
              
         if (c.Controls.Count > 0)
         {         
          IterateThroughChildren(c);         
         }
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-10-2005, 10:37 PM 12503 in reply to 11608

    Re: Dynamically Create/Update Cute Editor at run time

    Did you ever figure out a solution to your problem of retrieving the HTML from a dynamically generated editor?

    I have created an editor control and then iterated through the request.form values.  The posted data associated with the editor's ID contains some strange items (e.g. test becomes te#7t).

    Thanks
    ROB
  •  01-25-2012, 12:51 PM 72828 in reply to 11776

    Re: Dynamically Create/Update Cute Editor at run time

    Hi I am using CuteEditor6.6. I have the same issue. Any solution on this?
     
     
  •  01-25-2012, 12:56 PM 72829 in reply to 11608

    Re: Dynamically Create/Update Cute Editor at run time

  •  01-25-2012, 1:10 PM 72830 in reply to 72829

    Re: Dynamically Create/Update Cute Editor at run time

    Thanks! I got this part, but after user enter content in the editor, how do I get it from the editor since it is dynamically created.
     
     
View as RSS news feed in XML