[CLOSED] add multiple Labels in Codebehind

  1. #1

    [CLOSED] add multiple Labels in Codebehind

    Hi,
    I want add editable labels in codebehind. The count of labels depentds ao search result.
    Therfore I must add the Labels in codebehind.
    But when I generate the labels in a loop I alway get the error:


    Description: An
    unhandled exception occurred during the execution of the current web
    request. Please review the stack trace for more information about the
    error and where it originated in the code.

    Exception Details: System.ArgumentException: A
    Control with an ID of "False" has already been initialized. Please
    ensure that all Controls have a unique id.

    The following Control has the same ID as at least one other Control on the Page. All Controls must have a unique ID.

    *************************
    Control Details
    *************************

    ID: False.
    ClientID: False
    Type: Label

    *************************
    Parent Control Details
    *************************

    ID: Tab3
    ClientID: Tab3
    Type: Panel


    <%@ Page Language= "VB"%>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtmxl1/DTD/xht...ansitional.dtd">
        <style type="text/css">
         
    <%--     .editable
         {
          white-space:normal;
         }--%>
        </style>
    <script runat="server">
     Public ReadOnly Property Texts As List(Of String)
      Get
       Dim l As New List(Of String)
       'l.AddRange({"Elke"}) ', "Peter", "Dani"})
       l.AddRange({"Elke", "Peter", "Dani"})
       Return l
      End Get
     End Property
     
     'Dim l As New Ext.Net.Label  white-space from 'nowrap' to 'normal'.
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Dim p As New Ext.Net.Panel
      
      Session("Texts") = Texts
      Dim l As Ext.Net.Label
      Dim counter As Integer = 0
      For Each t In Texts
       l = New Ext.Net.Label
       With l
        .ID = "AjaxLab" = counter.ToString
        .Cls = "editable"
        .OverCls = "editable-over"
        .Html = t
       End With
          
       Dim edit As New Ext.Net.Editor
       With edit
        .ID = "edit" + counter.ToString
        .UpdateEl = False
       End With
       Dim par As New Ext.Net.Parameter
       With par
        .Name = "value" + counter.ToString
        .Value = "value" + counter.ToString
        .Mode = ParameterMode.Raw
       End With
       edit.DirectEvents.Complete.ExtraParams.Add(par)
       par = New Ext.Net.Parameter
       With par
        
        .Name = "Index" + counter.ToString
        .Value = counter.ToString
        .Mode = ParameterMode.Value
       End With
       edit.DirectEvents.Complete.ExtraParams.Add(par)
       AddHandler edit.DirectEvents.Complete.Event, AddressOf CompleteEdit
       l.Editor.Add(edit)
       Me.Form.Controls.Add(l)
       Me.Tab3.Add(l)
       counter = counter + 1
      Next
      Me.Tab3.Add(p)
     
     End Sub
     Public Sub CompleteEdit(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
      'Me.AjaxLabel.Text = e.ExtraParams("value1").ToString
      'Dim v = e.ExtraParams("mmmm").ToString
      'If e.ExtraParams("value") IsNot Nothing Then
      '   Dim n = e.ExtraParams("value").ToString
      'End If
      'Dim vb = e.ExtraParams("mmmm").ToString
     End Sub
    </script>
    >
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Editor Overview - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <style type="text/css">
            .editable {
                font: 14px Tahoma;
                padding: 3px 5px;
                cursor: pointer;
                margin-bottom: 20px;
            }
            .editable-over {
                background-color: #ffc;
            }
            .x-form-field-editor {
                font: 12px Tahoma;
            }
        </style>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Viewport ID="Viewport1" runat="server" Layout="fit">
                <Items>
                    <ext:TabPanel ID="TabPanel1" runat="server" Border="false">
                        <Defaults>
                            <ext:Parameter Name="BodyStyle" Value="padding:10px;" Mode="Value" />
                        </Defaults>
                        <Items>
                            <ext:Panel ID="Tab3" runat="server" Title="Ajax Update">
                                <Items>
    <%--                                <ext:Label 
                                        ID="AjaxLabel" 
                                        runat="server" 
                                        Cls="editable" 
                                        Icon="NoteEdit"
                                        OverCls="editable-over"
                      with="200"
                      html = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a urna. Praesent libero. Nullam vitae nisl. Maecenas pellentesque, magna eget pharetra fermentum, tortor dolor suscipit est, ultricies sollicitudin turpis orci vitae quam. Vestibulum augue diam, auctor ac, interdum eu, egestas ac, leo. Nulla justo mauris, mollis quis, consectetur non, varius ac, nunc. Sed facilisis. Sed elementum. Praesent tortor. Maecenas ipsum tellus, fringilla nec, scelerisque sed, scelerisque a, nulla. Phasellus eleifend interdum arcu. Nulla porta ligula placerat tortor.">
                                        <Editor>
                                            <ext:Editor ID="AjaxLabelEditor" runat="server" AutoSize="Width" UpdateEl="false">
                                                <DirectEvents>
                                                    <Complete OnEvent="CompleteEdit">
                                                        <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{Tab3}.body}" />
                                                        <ExtraParams>
                                                            <ext:Parameter Name="value" Value="value" Mode="Raw" />
                                                        </ExtraParams>
                                                    </Complete>
                                                </DirectEvents>
                                            </ext:Editor>                                                
                                        </Editor>
                                    </ext:Label>--%>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:TabPanel>
                </Items>
            </ext:Viewport>        
        </form>    
    </body>
    </html>

    Thanks for help
    Elke
    Last edited by Daniil; Sep 12, 2012 at 5:35 AM. Reason: [CLOSED]
  2. #2
    Hi Elke,

    I think the problem is here:
    .ID = "AjaxLab" = counter.ToString
    There is a boolean statement on the right.

    I would try to replace with
    .ID = "AjaxLab" & counter.ToString

Similar Threads

  1. EventEditWindow + Localize labels
    By bossun in forum 1.x Help
    Replies: 7
    Last Post: May 04, 2012, 11:37 PM
  2. [CLOSED] Multiple Editors - Multiple Instances?
    By jwf in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 09, 2011, 5:45 PM
  3. Editable Labels
    By KCoder in forum 1.x Help
    Replies: 6
    Last Post: Feb 15, 2010, 7:18 AM
  4. Htmlencode and labels - possible bug?
    By plykkegaard in forum 1.x Help
    Replies: 2
    Last Post: Apr 30, 2009, 11:12 AM
  5. [CLOSED] dynamic labels
    By alexp in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 10, 2009, 2:53 PM

Posting Permissions