More in this section

Forums / Developing with Sitefinity / Multiple Controls with same ID exception

Multiple Controls with same ID exception

10 posts, 0 answered
  1. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    21 May 2010
    Link to this post
    Hi Guys ,
                  Hope your all fine, and congrats on the sitefinity 4 beta, great work.

    I have placed 3 blog list controls on a single page and now when i run it it gives an exception of multiple control with same ID exist , the seems to be of a server control ct00 like that asp generates. Any insight our knowledge would really appreciated

    thank you


    Regards
    Adeel Arif
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 May 2010
    Link to this post
    Hello Adeel Arif,

    Could you please specify which version of the CMS are you using? Also are your controls, the stock ones or are they extended in some way - custom templates, or custom controls inheriting from from blog posts? I have tried this with the latest release of Sitefinity and the stock controls, however no error was thrown out.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    21 May 2010
    Link to this post
    I am using Sitefinity 3.7 and the custom templates "/Blogs/ContentViewItemList.ascx."

    i have checked the markup there is no control with the same id there.....

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContentViewItemList.ascx.cs"
        Inherits="Sitefinity_ControlTemplates_Blogs_ContentViewItemList" %>
    <%@ Register Assembly="Telerik.Blogs" Namespace="Telerik.Blogs.WebControls" TagPrefix="sfWeb" %>
    <%@ Register TagPrefix="cc1" Assembly="Telerik.Security" Namespace="Telerik.Security.WebControls" %>
    <telerik:CssFileLink ID="CssFileLink1" EmbeddedFileName="Telerik.Blogs.Resources.ControlTemplates.Frontend.blogsCommonLayout.css"
        FileName="" Media="screen" runat="server" />
    <sfWeb:HeaderLinks ID="headerLinks" runat="server" />
    <asp:HyperLink ID="backLink" runat="server" Text="<%$Resources:GoBack %>" />
    <asp:Repeater ID="repeater" runat="server">
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
            <table cellpadding="0" cellspacing="0" style="width: 100%;">
                <tr>
                    <td align="left" valign="top" style="width: 50px">
                        <asp:Image ID="imgAuthorOrPost" runat="server" Height="40px" Width="40px" />
                    </td>
                    <td valign="top">
                        <div style="font-family: Verdana; font-size: 12px; font-weight: bold; color: #ffffff">
                            <asp:HyperLink ID="fullContent1" runat="server">
                                <asp:Literal ID="Title" runat="server"></asp:Literal>
                            </asp:HyperLink>
                        </div>
                        <div style="font-family: Verdana; font-size: 10px; color: #cccccc; vertical-align: middle;">
                            <p class="sf_postAuthor">
                                <asp:Literal ID="Author" runat="server"></asp:Literal>
                                </asp:HyperLink> On
                                <telerik:DateTimeLiteral runat="server" ID="Publication_Date" Visible="false">
                                </telerik:DateTimeLiteral>
                            </p>
                        </div>
                        <font style="font-family:Verdana; font-size:11px; color:#D8D8D8;">
                            <asp:Literal ID="content" runat="server"></asp:Literal>
                        </font>
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <p class="sf_ReadMore" style="font-size: 9px">
                                        <asp:HyperLink ID="fullContent2" runat="server" ForeColor="#68a8f8">
                                            <asp:Literal ID="Literal7" runat="server" Text="<%$Resources:FullStory %>"></asp:Literal>
                                        </asp:HyperLink>
                                    </p>
                                </td>
                                <td>
                                    <p class="sf_ReadMore" style="font-size: 9px">
                                        <font color="white">  | </font>
                                        <asp:HyperLink ID="CommentsLink" runat="server" NavigateUrl="{0}#comments" ForeColor="#68a8f8">
                                            <asp:Literal ID="Literal1" Text="<%$Resources:Comments %>" runat="server"></asp:Literal>
                                            (<asp:Label ID="CommentsCount" runat="server"></asp:Label>)
                                        </asp:HyperLink><font color="white">  | </font><em>
                                            <asp:Literal ID="Literal2" Text="Last Comment:" runat="server"></asp:Literal>
                                            (<asp:Label ID="cDateString" runat="server"></asp:Label>) </em>
                                    </p>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <p class="sf_postTags">
                <asp:Repeater ID="Tags" runat="server">
                    <HeaderTemplate>
                        <asp:Literal ID="TagsLiteral" runat="server" Text="<%$Resources:Tags %>" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:HyperLink ID="tagLink" runat="server" />
                    </ItemTemplate>
                </asp:Repeater>
            </p>
            <hr align="center" width="500px" style="color: Gray;" />
        </ItemTemplate>
        <FooterTemplate>
            <table align="right" cellpadding="0" cellspacing="1">
                <tr>
                    <td style="background-image: url(Images/btns/blank.png); background-repeat: no-repeat;
                        width: 94px; height: 25px; color: Black; font-family: Tahoma; font-size: 11px;
                        text-align: center">
                        <a  href="~/TangoBlogPage.aspx" runat="server" style="color: Black">View All Threads</a>
                    </td>
                    <td style="background-image: url(Images/btns/blank.png); background-repeat: no-repeat;
                        width: 94px; height: 25px; color: Black; font-family: Tahoma; font-size: 11px;
                        text-align: center;">
                        <a href="~/PostNewBlogTopic.aspx" runat="server" style="color:black">
                        Create Threads
                        </a>
                    </td>
                </tr>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    <telerik:Pager ID="pager1" runat="server">
        <LayoutTemplate>
            <asp:Repeater ID="PageRepeaterLinkButton" runat="server">
                <HeaderTemplate>
                    <asp:LinkButton ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:LinkButton>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="SingleItem" runat="server" />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:LinkButton ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:LinkButton>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Repeater ID="PageRepeaterHyperLink" runat="server">
                <HeaderTemplate>
                    <asp:HyperLink ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:HyperLink>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:HyperLink ID="SingleItem" runat="server" />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:HyperLink ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:HyperLink>
                </FooterTemplate>
            </asp:Repeater>
        </LayoutTemplate>
    </telerik:Pager>

    .cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Cms.Web.UI;
    using Telerik.Cms.Engine;
    using System.Collections;
    public partial class Sitefinity_ControlTemplates_Blogs_ContentViewItemList : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
        }
     
        void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                     #region Get and SHow LatestCommentDate
                Guid bID = Guid.Empty;
     
                Telerik.Cms.Engine.IContent blogItem = (Telerik.Cms.Engine.IContent)e.Item.DataItem;
                Guid blogItemID = blogItem.ID;
                // Literal blogItemIDLiteral = e.Item.FindControl("blogItemIDLiteral") as Literal;
     
                bID = new Guid(blogItemID.ToString());
     
                 
                IList commentsList = ContentManager.Providers["Blogs"].GetComments(bID, true, "DateCreated DESC");
                if (commentsList.Count > 0)
                {
                    IComment last = commentsList[0] as IComment;
                    DateTime dt = last.GetCreationDate();
                    Label dateLabel = e.Item.FindControl("cDateString") as Label;
                    dateLabel.Text =Elixir.Dashboard.Tango.General.GetDateTimeDifference(dt.Date,5);//.ToShortDateString()+".";
                }
                else
                {
                    Label dateLabel = e.Item.FindControl("cDateString") as Label;
                    dateLabel.Text = "Never";
                }
                #endregion
                    Literal author = e.Item.FindControl("Author") as Literal;
                     
     
                    ProfileCommon profile = Profile.GetProfile(author.Text);              
                    if(!String.IsNullOrEmpty(profile.Position))
                        author.Text += " ("+profile.Position+")";
     
     
                    Image imgAuthorOrPost = e.Item.FindControl("imgAuthorOrPost") as Image;
                    imgAuthorOrPost.ImageUrl = profile.Photo;
                    imgAuthorOrPost.ToolTip = profile.FirstName + " " + profile.LastName;
     
                   
     
                    /*
                    Image blogImage = e.Item.FindControl("BlogImage") as Image;
                    Literal image = e.Item.FindControl("Image") as Literal;
                    if (blogImage != null && image != null)
                    {
                        string item = image.Text;
     
                        Guid guid = new Guid(item.Substring(item.IndexOf("]") + 1));
                        Telerik.Libraries.LibraryManager manager = new Telerik.Libraries.LibraryManager();
                        Telerik.Cms.Engine.IContent cnt = manager.GetContent(guid);
                        blogImage.ImageUrl = cnt.UrlWithExtension;
                    }
                     * */
     #region Code to Set time in Publication_Date as well.
                
                    DateTimeLiteral Publication_Date = e.Item.FindControl("Publication_Date") as DateTimeLiteral;
                    Publication_Date.DateFormatString = "MMMM d, yyyy - HH:mm ";
                    Publication_Date.Visible = true;
                 
                #endregion
                     
                }
           
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect(Elixir.Dashboard.Tango.General.GenerateNewBlogPostTopicLink(Request.Url.AbsolutePath));
        }
    }
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 May 2010
    Link to this post
    Hi Adeel Arif,

    I have used your template for my Blog Posts control, however I am not able to see the exception. All I noticed is that you had on </asp:Hyperlink> closing tag which was missing the opening one:
    <div style="font-family: Verdana; font-size: 10px; color: #cccccc; vertical-align: middle;">
        <p class="sf_postAuthor">
            <asp:Literal ID="Author" runat="server"></asp:Literal>
            </asp:HyperLink> On
            <telerik:DateTimeLiteral runat="server" ID="Publication_Date" Visible="false">
            </telerik:DateTimeLiteral>
        </p>
    </div>


    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    21 May 2010
    Link to this post
    sorry my bad, but even removing that i still get the same message one thing more i have trace enabled, and below is the complete exception that i get


    Multiple controls with the same ID 'ctl00$link' were found. Trace requires that controls have unique IDs.

    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.Web.HttpException: Multiple controls with the same ID 'ctl00$link' were found. Trace requires that controls have unique IDs.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Multiple controls with the same ID 'ctl00$link' were found. Trace requires that controls have unique IDs.]
       System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize, Int32 controlStateSize) +426
       System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +344
       System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +426
       System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +426
       System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +426
       System.Web.UI.Page.BuildPageProfileTree(Boolean enableViewState) +39
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5792
    
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 May 2010
    Link to this post
    Hello Adeel Arif,

    Now that you mention that you have trace enabled - if you disable it all should be fine. It seems to be some problem when the control client IDs are generated by ASP.NET. I have seen this error with trace enabled before, however I am not quite sure why it is happening so, because when I look at the page html output there are no controls with the same client ID.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    26 May 2010
    Link to this post
    Some thing weird is going on now there is no trace enabled and when i click on the forums link to navigate to the respective forum. I get the following exception

    Server Error in '/TangoDashboard' Application.

    Multiple controls with the same ID 'link' were found. FindControl requires that controls have unique IDs.

    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.Web.HttpException: Multiple controls with the same ID 'link' were found. FindControl requires that controls have unique IDs.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Multiple controls with the same ID 'link' were found. FindControl requires that controls have unique IDs.]
       System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +273
       System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +320
       System.Web.UI.Control.EnsureNamedControlsTable() +61
       System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +222
       System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327
       System.Web.UI.Page.FindControl(String id) +38
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +113
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053



    the control is forums list (control template's) control.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 May 2010
    Link to this post
    Hello Adeel Arif,

    Are you using the stock template? We do not have any controls with ID link there. For reference the control template is attached to this ticket.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Adeel Arif
    Adeel Arif avatar
    27 posts
    Registered:
    30 Dec 2009
    27 May 2010
    Link to this post
    Hi all,
             Thanks for the helping hand there , i thought i should share that i managed to solve the problem but still i do not understand why this happened, i was calling the method on page load i.e Page.header.DataBind() and Page.Databind() previously all was working fine since this Error , by removing the above two function calls the Exception was no more. :-)

    Regards
    Adeel Arif.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 May 2010
    Link to this post
    Hi Adeel Arif,

    You are calling DataBind too soon. You are calling something that is not part of the  page controls hierarchy yet.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
10 posts, 0 answered