Link to home
Start Free TrialLog in
Avatar of Sebastian_OH
Sebastian_OH

asked on

Two components with the Same id can't be added to the application

Hi,

i have a problem with a slider control in one of my user controls. The user control has a modal popup extender with a slider control.
When i load the page for the first time, everything works great. After a second postback i get the error message shown bellow and the slider control is not turning into the visible textbox.


Message: Sys.InvalidOperationException: Two components with the same id 'TabContainer1_tabParts_Tab1Ctrl_sldQuantity' can't be added to the application.
Line: 4044
Char: 59
Code: 0
URI: http://localhost:59170/ScriptResource.axd?d=3Eg-fQsMWKYsGzpai2d16FzRZyxePoVWg0ZiVzxl0IzKq1Ft9y3T2wENj7O3x_hyqAvmWHH4ztSWl-WP85md5YtGYn_v721mKRQ3_QCPeFk1&t=ffffffffec2d9970



What could be the problem?

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Parts.ascx.cs" Inherits="ADDTest.Parts1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<link rel="Stylesheet" type="text/css" href="Styles/Stylesheet.css" id="style" runat="server" visible="false" />
                  
    <div style="height: 445px; vertical-align: top;" id="divParts">               
        <table width="100%">
            <tr valign="top">
                <td width="25%">
                    <div id="divSearch">
                    <p class="text">Search:</p>
                        <asp:TextBox ID="txtSearch" runat="server" Width="169px" 
                            ontextchanged="txtSearch_TextChanged"> 
                        </asp:TextBox>
                        <asp:DropDownList ID="ddlSearch" Width="91px" Height="22px" runat="server" AutoPostBack="True"
                        onselectedindexchanged="ddlSearch_SelectedIndexChanged" >
                            <asp:ListItem selected="True">Description</asp:ListItem>
                            <asp:ListItem>Manufacturer</asp:ListItem>
                            <asp:ListItem>Part ID</asp:ListItem>
                            <asp:ListItem>Bin Loc.</asp:ListItem>
                        </asp:DropDownList>
                        
                        <br />
                        <asp:Button ID="btnSearch" runat="server" Text="Search" 
                            onclick="btnSearch_Click" />
                        <asp:Button ID="btnClear" runat="server" Text="Clear" 
                            onclick="btnClear_Click" />
                        <br />
                        <br />
                        <asp:ListBox ID="lbxSearch" runat="server" Height="260px" Width="265px" 
                             SelectionMode="Multiple">
                        </asp:ListBox>
                        <br />
                        <asp:Button ID="btnShow" runat="server" Text="Show Images" 
                        onclick="btnShow_Click" /> 
                        </div>
                        <div id="divSearchBottom">
                            <asp:LinkButton ID="lbtnCheckout" runat="server" PostBackUrl="~/ViewCart.aspx"></asp:LinkButton>
                        </div>
                </td>
                <td width="75%" valign="top">
                
                    <div>
                    
                        <asp:DataList ID="DataList1" runat="server"  
                            RepeatColumns="3" RepeatDirection="Horizontal" BackColor="White" 
                            BorderColor="#E26020" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                            GridLines="Both"  >
                                <FooterStyle BackColor="#99CCCC" ForeColor="#E26020" />
                                <ItemTemplate>
                                <div class="Part">
                                <div class="PartImage">
                                    <table>
                                        <tr>
                                            <td>
                                                <asp:Image ID="imgPart" runat="server" Height="50" ImageUrl='<%#"ViewImage.ashx?part=" + Eval("Part") %>' 
                                                    GenerateEmptyAlternateText="true" Width="75" AlternateText="No Image" 
                                                    onmouseover="zoomToggle('100px','100px','200px','200px',this);" />
                                            </td>
                                            <td>
                                                <asp:Button ID="btnAdd" runat="server" Text="Add to Cart" Height="20px" 
                                                    CommandArgument='<%# Eval("Part") %>' CommandName="Action" onCommand="btnAdd_Command" />    
                                                <cc1:ModalPopupExtender ID="ModalPop" runat="server"
                                                    TargetControlID="btnAdd" PopupControlID="pnlAddPart" 
                                                    CancelControlID="btnPnlCancle" BackgroundCssClass="Modalbackground" 
                                                    DynamicContextKey='<%# Eval("Part") %>' DynamicServiceMethod="PopupMethod" DynamicControlID="txtHidden"  />
                                            <%--<asp:Button ID="btnDetails" runat="server" Text="Details" Height="20px" CommandArgument='<%# Eval("Part") %>' />  --%>
                                            </td>
                                        </tr>
                                    </table> </div>
                                <div class="PartDetails"></div>
                                    
                                    Part:
                                    <asp:TextBox ID="Parttext" runat="server" ReadOnly="True" TextMode="SingleLine" BorderStyle="None" BorderWidth="0" CssClass="textbox" Text='<%# Eval("Part") %>'></asp:TextBox> 
                                    <br />
                                    Desc.: 
                                    <asp:TextBox ID="Desc1Text" runat="server" Rows="2" ReadOnly="True" TextMode="MultiLine" BorderStyle="None" BorderWidth="0" CssClass="textbox" Text='<%# Eval("Desc1") %>'></asp:TextBox>
                                    <br />
                                    Inv: <asp:TextBox ID="InvText" runat="server" ReadOnly="True" TextMode="SingleLine" BorderStyle="None" BorderWidth="0" CssClass="textbox" Text='<%# Eval("Inv") %>' Width="147px"></asp:TextBox>
                                    <br />
                                    BinLoc:<asp:TextBox ID="BinLocText" runat="server" ReadOnly="True" TextMode="SingleLine" BorderStyle="None" BorderWidth="0" CssClass="textbox" Text='<%# Eval("BinLoc") %>' Width="126px"></asp:TextBox>
                                    <br />
                                    Manufacturer: <asp:TextBox ID="ManufacturerText" runat="server" ReadOnly="True" TextMode="SingleLine" BorderStyle="None" BorderWidth="0" CssClass="textbox" Text='<%# Eval("Manufacturer") %>' Width="85px"></asp:TextBox>
                                    <br />
                                </div>
                                </ItemTemplate>
                                <ItemStyle BackColor="White" ForeColor="#E26020" />
                                <SelectedItemStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                        </asp:DataList>
                        </div>
                        
                        <div id="Navigation" class="navigation" runat="server">

                            <div id="leftnav">
                                <asp:Button ID="btnPreviousPage" runat="server" Text="Previous Parts" OnClick="btnPreviousPage_Click" />
                                &nbsp;
                            </div>
                            
                            <div id="rightnav">
                                &nbsp;
                                <asp:Button ID="btnNextPage" runat="server" Text="More Parts"  OnClick="btnNextPage_Click" />
                            </div>
                        
                            <div id="numnav">
                                <asp:Label ID="PagerLocation" runat="server" />
                            </div>
                        
                        </div>
                </td>
            </tr>
        </table>
 </div> 
 
<asp:Panel ID="pnlAddPart" runat="server" style="display:none">

    <asp:ObjectDataSource ID="odsChrgDep" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="ADDTest.Datasets.dsCribstoreTableAdapters.ChrgDepTableAdapter"></asp:ObjectDataSource>
  <asp:UpdatePanel ID="upAddPart" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <h1>Select Quantity:</h1>
        <asp:TextBox ID="txtHiddenSlider" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtVisibleSlider" runat="server"></asp:TextBox>
        <cc1:SliderExtender ID="sldQuantity" runat="server" 
            TargetControlID="txtHiddenSlider" BoundControlID="txtVisibleSlider" 
            Maximum="50" Minimum="1" />      
        <asp:RangeValidator ID="RangeValidator1" runat="server" 
            ErrorMessage="RangeValidator" ControlToValidate="txtVisibleSlider" 
            MaximumValue="10" MinimumValue="1" Font-Bold="True" Font-Italic="True" 
            Font-Size="Large" Type="Integer" >Not enough Parts in Stock</asp:RangeValidator>
        <br />
        <h1>Select Charge Department:</h1>
        <asp:DropDownList ID="ddlPnl" runat="server" DataSourceID="odsChrgDep" 
            DataTextField="ChrgDepDesc" DataValueField="ChrgDep" />  
            <br />
        <asp:Button ID="btnPnlOk" runat="server" Text="OK" onClick="btnPnlOk_Click" /> 
        <asp:Button ID="btnPnlCancle" runat="server" Text="Cancle" />
        <asp:TextBox ID="txtHidden" runat="server" style="display:none" />
  </ContentTemplate>
 </asp:UpdatePanel>
</asp:Panel>

Open in new window

Avatar of Bardobrave
Bardobrave
Flag of Spain image

It's only an idea... but maybe your object is still in memory when you make the second call? Maybe if you erase it from memory when the page unloads the problem dissappear.
Avatar of Sebastian_OH
Sebastian_OH

ASKER

Thanks for the relpy.
How can i unload it ?

ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You pointed me in the right direction.
In my main page i have the User Control show above in an update panel. For some reason that forced the control to be loaded twice. After removed the update panel and placed it in the user control everything works.