Hi abyssknight,
How to get the clientId of editors which created dynamically.
- <%@ Page Language="C#" %>
-
- <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
- <html>
- <head>
- <title>example</title>
- </head>
- <body>
- <form id="Form1" runat="server">
- <h4>
- How many Editors would you like to create? (<i>Please choose vaule between 1 and 10</i>)</h4>
- <asp:TextBox runat="Server" ID="txtTBCount" Columns="3" /><br />
- <br />
- <asp:Button runat="server" Text="Create Editors" OnClick="CreateEditors" ID="Button1" />
- <input type="button" value="Show all editor client id" onclick="showAllEditorId()" />
- <asp:PlaceHolder runat="server" ID="EditorsHere" />
- <asp:HiddenField ID="idList" runat="server" />
- </form>
- </body>
- </html>
-
- <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 ="my clientId is: "+ c.ClientID;
- ((CuteEditor.Editor)c).AutoConfigure = AutoConfigure.Simple;
- ((CuteEditor.Editor)c).Height = 200;
- ((CuteEditor.Editor)c).ThemeType = ThemeType.OfficeXP;
- idList.Value += c.ClientID;
- idList.Value += "-------";
- count++;
- }
-
- if (c.Controls.Count > 0)
- {
- IterateThroughChildren(c);
- }
- }
- }
-
- void CreateEditors(Object sender, EventArgs e)
- {
-
- int n = Int32.Parse(txtTBCount.Text);
-
-
- for (int i = 0; i < n; i++)
- {
- EditorsHere.Controls.Add(new CuteEditor.Editor());
- }
-
-
- IterateThroughChildren(this);
- }
- </script>
-
- <script>
-
- function showAllEditorId()
- {
- var idList=document.getElementById("<%= idList.ClientID %>");
- alert(idList.value);
- }
- </script>
Regards,
Ken