saurabh
saurabh

Reputation: 17

How to use multiple ajax calendars in a single page

I am trying to use a calendar to insert dates. Unfortunately, I have to use more than one calendar. For extracting the date from the calendar, I am using Ajax toolkit

`<cc1:ToolkitScriptManager ID="ToolkitScriptManager1"  EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
            </cc1:ToolkitScriptManager>

<asp:TextBox ID="DateOfPurchase" runat="server"  Height="30px" ReadOnly="true" Width="262px"></asp:TextBox>

            <asp:ImageButton ID="imgPopup" ImageUrl="images/index.jpg" ImageAlign="Bottom"
            runat="server" Height="27px" Width="37px" />

            <cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="DateOfPurchase"
            Format="dd/MM/yyyy">
            </cc1:CalendarExtender>`

So whenever I add more than one <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server"> </cc1:ToolkitScriptManager> my program shows error. And if I use Only one ToolkitScriptManager and multiple Ajax calendar controls, clicking on only one image button for displaying the calendar, all the calendars,on the page, pops up.

Upvotes: 0

Views: 521

Answers (1)

Stefano Losi
Stefano Losi

Reputation: 729

Each CalendarExtender must have its own ID

        <asp:ImageButton ID="imgPopup1" ImageUrl="images/index.jpg" ImageAlign="Bottom"
        runat="server" Height="27px" Width="37px" />

        <cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup1" runat="server" TargetControlID="DateOfPurchase1"
        Format="dd/MM/yyyy">
        </cc1:CalendarExtender>`

        <asp:ImageButton ID="imgPopup2" ImageUrl="images/index.jpg" ImageAlign="Bottom"
        runat="server" Height="27px" Width="37px" />

        <cc1:CalendarExtender ID="Calendar2" PopupButtonID="imgPopup2" runat="server" TargetControlID="DateOfPurchase2"
        Format="dd/MM/yyyy">
        </cc1:CalendarExtender>`

Upvotes: 1

Related Questions