Search code examples
javascriptasp.netajaxcontroltoolkit

Asp.net displaying the same date in two ajax calendar_extender


I have a problem with some ajax calendar extenders. I have similiar 2 calendars and two textboxes that are each linked to one calendar.

                        <asp:TextBox ID="txt1" runat="server"</asp:TextBox>
                    <cc1:CalendarExtender ID="calendar1" runat="server" TargetControlID="txt1"
                        Format="yyyy-MM-dd" CssClass="Calendars" Enabled="false">

When I select a date in the first calendar, I want the second calendar to place itself in the same month as the first calendar but without selecting the actual date (because doing so will make the txt2 display that date). The txt2 textbox should remain empty until a date is selected by the user in calendar2.

I have look everywhere on the internet but nothing seems to fit that situation.

can anybody help?

EDIT:

I have tried to change the date and then erase the textbox with javascript but I have a compare validator that triggers when I do so. I use the following javascript code to erase the textbox:

        function onShowingCal2(sender, e) {
        var txt2 = document.getElementById('<%= txt2.ClientID %>');
        var txt1 = document.getElementById('<%= txt1.ClientID %>');
        var cal2 = sender;
        if (txt2.value == "") {
            var dateStart = new Date();
            dateStart.setDate(txt1.value);
            cal2.set_selectedDate(dateStart );
            datechosen = false;                
        }
    }
function onTextboxChange() {
            if (!datechosen ) {
                document.getElementById('<%= txt2.ClientID %>').value = "";
            }
        }

thanks!


Solution

  • I finnaly got something working

    What I did is I took the javascript code in the question and added one very simple function:

            function EndDateChosen(e) {
            dateChosen = true;
        }
    

    And call this like so in the calendar2 tag's property OnClientDateSelectionChanged='EndDateChosen'

    that event was a pain to make work. The javascript fonction HAS to have ONLY one parameter and the fonction name in the calendar's tag HAS to be surrounded with single quotes not doubleQuotes.

    thanks yall!