不能将具有相同ID"calender1"的两个组件添加到应用程序中 [英] Two components with the same id 'calender1' can't be added to the application
问题描述
在我的asp.net项目中,在我的页面中,我具有gridview,其中有一个文本框和日历控件,如下所示:
In my asp.net project, In my page I have gridview in that I have a text box and calender control like the following
<asp:TemplateField HeaderText="Year">
<ItemTemplate>
<asp:TextBox ID="txtCourseYear" runat="server" Width="80px" MaxLength="10" Text='<%# Eval("YearPassed") %>'></asp:TextBox>
<asp:Image ID="Image3" runat="server" ImageUrl="~/images/Calender.JPG" Style="width: 16px" />
<asp:CalendarExtender ID="CalendarExtender_txtYear" runat="server" Enabled="True"
TargetControlID="txtCourseYear" Format="yyyy" OnClientShown="onCalendarShown"
BehaviorID="calendar1" OnClientHidden="onCalendarHidden" PopupButtonID="Image3">
</asp:CalendarExtender>
</ItemTemplate>
</asp:TemplateField>
执行项目时出现以下错误..
Calendar Extender生成消息"Sys.InvalidOperationException:不能将具有相同ID"calender1"的两个组件添加到应用程序中.
我认为BehaviorID将动态更改,我该怎么做.>
我试图将BehaviouId calender1更改为calender2,但是发生了相同的错误..
我如何解决此问题.....
while executing the project I am getting the following error..
Calendar Extender generates message "Sys.InvalidOperationException: Two components with the same id ''calender1'' can''t be added to the application
I think the BehaviorID will change dynamically How i can do this.>
I tried to Change BehaviouId calender1 to calender2 but same error occured..
How I can solve this Issue.....
推荐答案
您的页面有两个具有相同ID的CalendarExtender
控件.
根据您的示例代码,其他控件的BehaviorID
可能也相同.对其进行更改(例如calendar2),它应该可以正常工作.
You page has twoCalendarExtender
control used with the same id.
As per your sample code, probably theBehaviorID
of other control is same as well. Change it (to say calendar2) and it should work.
这篇关于不能将具有相同ID"calender1"的两个组件添加到应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!