Nov 18, 2009, 9:18 AM
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.
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.