Re: Dynamically Create/Update Cute Editor at run time

  •  10-11-2005, 4:15 PM

    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

View Complete Thread