Cotrol Id confliction when using multiple instance of User control on same page

  1. #1

    Cotrol Id confliction when using multiple instance of User control on same page

    Hi,

    Please help me to fix this problem.

    I am trying to use multiple instance of user control on same page but getting following error.

    <h2>A Control with an ID of "dsAllTasks" has already been initialized. Please ensure that all Controls have a unique id.</h2>
    I have placed a store and grid panel on my user control like this.

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
    
      
        //public Coolite.Ext.Web.Store DataStore { get; set; }
        public string StoreURL {
            get { HttpProxy httpProxy = this.dsAllTasks.Proxy.Proxy as HttpProxy;
            if (httpProxy !=null)
            {
                return httpProxy.Url;
                
            }
            return null;
            }
            set
            {
                HttpProxy httpProxy = new HttpProxy();
    
                httpProxy.Url = value;
               dsAllTasks.Proxy.Add(httpProxy);
                
            }
         }
        
     
    
     
    </script>
    <ext:Store ID="dsAllTasks" runat="server" ShowWarningOnFailure="true">
     
       
            <Reader>
                <ext:JsonReader ReaderID="TaskId" Root="data" TotalProperty="totalCount">
                    <Fields>
                  <ext:RecordField Name="TaskId"/>
                 <ext:RecordField Name="TaskName"/>
                <ext:RecordField Name="StartDate"/>
                 <ext:RecordField Name="ExpectedEndDate"/>
                <ext:RecordField Name="Completion %"/>
                
                    </Fields>
                </ext:JsonReader>
            </Reader>
                 
        </ext:Store>
    <ext:GridPanel ID="grdTasks" runat="server" Header="false" Border="false" 
       StoreID="dsAllTasks"     TrackMouseOver="true" ClicksToEdit="1">
            <ColumnModel ID="tasksColModel" runat="server">
                <Columns>
                    <ext:Column   Header="Task Name" DataIndex="TaskName">          
     
                    </ext:Column>
                    <ext:Column   Header="Priority">          
     
                    </ext:Column>
                       <ext:Column  Header="Project Name" >   
     
                    </ext:Column>
                    <ext:Column  Header="Start Date" DataIndex="StartDate" >
     
                    </ext:Column>
                     <ext:Column   Header="End Date" DataIndex="ExpectedEndDate">
     
                    </ext:Column>
                      <ext:Column   Header="completion(%)" DataIndex="Completion %">
     
                    </ext:Column>
                </Columns>
            </ColumnModel>
    
        </ext:GridPanel>
    now i am trying to use multiple instance of this user control like this.

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ Register src="TaskControl.ascx" tagname="TaskControl" tagprefix="uc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>MyTasks</title>
    </head>
    <body>
    <form>
    <ext:ScriptManager ID="scriptManager" runat="server" />
     <uc1:TaskControl ID="todayTasks" runat="server" StoreURL="/Data/GetAllTasks/" />
     
      <uc1:TaskControl ID="TaskControl1" runat="server" StoreURL="/Data/GetAllTasks/" />
     </form>
     
        
    
    </body>
    </html>
    More over if i try to use a single instance of user control it all works fine.

  2. #2

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    Hi,

    Did you specify IDMode="Static" anywhere? For example, do you have coolite section with custom IDMode in the web.config?
  3. #3

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    Hi vladimir,

    thanks for quich responce

    my coolite section settings is web config is like this

        <coolite idMode="Explicit" theme="Slate" initScriptMode="Linked" scriptMode="Debug"/>
    so idmode is explicit. is that correct?
    <h2><a &#111;nmouseover="window.status = window.location;return true;" &#111;nmouseout="window.status='';return true;" title="View vladimir's Profile..." id="ctl10_ctlTopic_ctlPanelBar_ctlTopicsRepeater_c tl05_smAuthorName" href="void('');">
    </a></h2>
  4. #4

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    If idMode="Explicit", then you must ensure the component id's are unique. If two components have the same id, the exception you posted above will be thrown.



    Geoffrey McGill
    Founder
  5. #5

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    what idmode i should mention in coolite section in configuration, so that two instance of same user control on one page can be rendered without any error .
  6. #6

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    shailendra (11/18/2009) what idmode i should mention in coolite section in configuration, so that two instance of same user control on one page can be rendered without any error .
    Just remove idMode="Explicit" from your Web.config and your sample should work fine.


    Geoffrey McGill
    Founder
  7. #7

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    if i am removing idmode nothing is rendering any more
  8. #8

    RE: Cotrol Id confliction when using multiple instance of User control on same page

    Hi,

    I have explicitly set idmode of each control inside user control to Ignore and now its working fine :)

    thanks

Similar Threads

  1. Replies: 7
    Last Post: Jan 29, 2013, 11:59 AM
  2. Display multiple user control in a master page
    By maruf.zaman in forum 1.x Help
    Replies: 0
    Last Post: Jan 11, 2012, 11:39 AM
  3. Replies: 7
    Last Post: Jun 28, 2011, 11:13 AM
  4. Replies: 7
    Last Post: Apr 14, 2011, 10:52 PM
  5. Replies: 2
    Last Post: Aug 27, 2009, 8:12 AM

Posting Permissions