[RESOLVED]Calendar Extender getting date and time?

Hi,

Here is my sample html:

<asp:TextBox runat="server" ID="TextBox_gidis_tarih" Text=""></asp:TextBox>
...
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="<%$ Resources:Seyahat, RequiredFieldValidator4 %>"
                        Text='<img src="Images/validation_error.png">' ControlToValidate="TextBox_gidis_tarih"
                        SetFocusOnError="True" Display="None"></asp:RequiredFieldValidator>
                    <asp:ValidatorCalloutExtender runat="Server" ID="ValidatorCalloutExtender4" TargetControlID="RequiredFieldValidator4"
                        Width="200px" HighlightCssClass="highlight" />
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" ControlToValidate="TextBox_gidis_tarih"
                        ValidationExpression="^(([0-2]d|[3][0-1])/([0]d|[1][0-2])/[2][0]d{2})$|^(([0-2]d|[3][0-1])/([0]d|[1][0-2])/[2][0]d{2}s([0-1]d|[2][0-3]):[0-5]d:[0-5]d)$"
                        ErrorMessage="<%$ Resources:Seyahat, RegularExpressionValidator4 %>" Text='<img src="Images/validation_error.png">'
                        EnableClientScript="true" runat="server" SetFocusOnError="True" Display="None" />
                    <asp:ValidatorCalloutExtender runat="Server" ID="ValidatorCalloutExtender5" TargetControlID="RegularExpressionValidator4"
                        Width="200px" HighlightCssClass="highlight" />
                    <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="TextBox_gidis_tarih"
                        Text='<img src="Images/validation_error.png">' ControlToCompare="TextBox1" Operator="GreaterThanEqual"
                        Type="Date" ErrorMessage="<%$ Resources:Seyahat, CompareValidator2 %>" Font-Bold="True"
                        SetFocusOnError="True" Display="None"></asp:CompareValidator>
                    <asp:ValidatorCalloutExtender runat="Server" ID="ValidatorCalloutExtender6" TargetControlID="CompareValidator2"
                        Width="200px" HighlightCssClass="highlight" />
                    <asp:CompareValidator ID="CompareValidator5" runat="server" ControlToValidate="TextBox_gidis_tarih"
                        Text='<img src="Images/validation_error.png">' ControlToCompare="TextBox_donus_tarih"
                        Operator="LessThanEqual" Type="Date" ErrorMessage="<%$ Resources:Seyahat, CompareValidator5 %>"
                        Font-Bold="True" SetFocusOnError="True" Display="None"></asp:CompareValidator>
                    <asp:ValidatorCalloutExtender runat="Server" ID="ValidatorCalloutExtender7" TargetControlID="CompareValidator5"
                        Width="200px" HighlightCssClass="highlight" />
                    <asp:CalendarExtender ID="TextBox_gidis_tarih_CalendarExtender" runat="server" Format="dd/MM/yyyy HH:mm:ss"
                        BehaviorID="Calender1" OnClientDateSelectionChanged="dateselect" TargetControlID="TextBox_gidis_tarih">
                    </asp:CalendarExtender>

And here is my javascript:

function dateselect(ev) {
            var cal = "<%= TextBox_gidis_tarih_CalendarExtender.BehaviorID %>";
            var calendarBehavior1 = $find("#" + cal);
            var d = calendarBehavior1._selectedDate;
            var now = new Date();
            calendarBehavior1.get_element().value = d.format("MM/dd/yyyy") + " " + now.format("HH:mm:ss")

        }

Here is why I decided to use dateselect function: http://forums.asp.net/p/1414231/3111375.aspx

But the problem is, it still set 00:00:00 to time. How can I fix this?

Best Regards.

This worked.

var cal = "<%= TextBox_gidis_tarih_CalendarExtender.BehaviorID %>";

            var calendarBehavior1 = $find(cal);

Leave a Reply