Click here to Skip to main content
15,916,215 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my asp.net project, In my page I have gridview in that I have a text box and calender control like the following

XML
<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>



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.....
Posted
Updated 25-Sep-12 20:02pm
v2

1 solution

You page has two CalendarExtender control used with the same id.

As per your sample code, probably the BehaviorID of other control is same as well. Change it (to say calendar2) and it should work.
 
Share this answer
 
Comments
honey4bee 26-Sep-12 1:59am    
Ur gess is correct, I have already tried above wt u said I m binding that from database, for same problem coming for that also........
Ankur\m/ 26-Sep-12 2:05am    
I am sorry I didn't understand your comment. Could you please explain considering the fact that I know nothing about what you are doing.
honey4bee 26-Sep-12 3:05am    
calendar2 not working.....
if we can change BehaviouId dynamically then my problem will be solved..
Ankur\m/ 26-Sep-12 4:29am    
I am sure there should be a property for that. Every time you are creating the control dynamically, set the property to a different value.
honey4bee 26-Sep-12 4:46am    
I have given BehaviorID="calendar2" but not working, for this also I m getting the same problem.
I m using Javascript funciton also..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900