Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I have a date picker control once the user enters the OnLeaveStartDate ,and then if he decides not to enter the date ,the date is not being disabled,on pressing the backspace,the entire page Traverses back.

below is what I'm doing

HTML
 <div class='sxro sx3co'>
                        <div class="sxlb">
                            <asp:Label ID="lblSupplierOnLeaveStartDate" runat="server" AssociatedControlID="dpSupplierOnLeaveStartDate"
                                Text="On-leave Start Date"></asp:Label></div>
                        <div class="sxlm">
                            <asp:DatePicker  runat="server" ID="dpSupplierOnLeaveStartDate" DateInput-ReadOnly="true"
                                DateInput-DateFormat="MM-dd-yyyy" Width="99%">
                                <ClientEvents OnPopupClosing="FocusOnPopUpButton"  önDateSelected="SetSupplierOnLeaveStartDateSelected" />
                                <Calendar ID="calSupplierOnLeaveStartDate"  runat="server" EnableKeyboardNavigation="true"
                                    CausesValidation="false">
                                </Calendar>
                            </asp:DatePicker>
                            <div class="vldx">
                                <asp:RequiredFieldValidator runat="server" ID="rfvSupplierOnLeaveStartDate" ControlToValidate="dpSupplierOnLeaveStartDate"
                                    class="errmsg" ValidationGroup="grpSupplierInformation" Display="Dynamic" ErrorMessage="SUPPLIER_ONLEAVE_START_DATE_MANDATORY"
%>'
                                    Enabled="false" />
                                <asp:CompareValidator ID="cmpSupplierOnLeaveStartDate" ControlToValidate="dpSupplierOnLeaveStartDate"
                                    class="errmsg" ValidationGroup="grpSupplierInformation" Operator="GreaterThanEqual"
                                    Display="Dynamic" ValueToCompare='<%# DateTime.Today.ToShortDateString() %>'
                                    Type="Date" runat="server" ErrorMessage="SUPPLIER_ONLEAVE_START_DATE_GRATER_THAN_CURRENT_DATE" %>'></asp:CompareValidator>
                            </div>
                        </div>
                        <div class="sxlb">
                            <asp:Label ID="lblSupplierOnLeaveEndDate" runat="server" AssociatedControlID="dpSupplierOnLeaveEndDate"
                                Text="On-leave End Date"></asp:Label></div>
                        <div class="sxlm">
                            <:asp:DatePicker  runat="server" ID="dpSupplierOnLeaveEndDate" DateInput-ReadOnly="true"
                                DateInput-DateFormat="MM-dd-yyyy" Width="99%">
                                <ClientEvents OnPopupClosing="FocusOnPopUpButton"  önDateSelected="SetSupplierOnLeaveEndDateSelected" />
                                <Calendar ID="calSupplierOnLeaveEndDate"  runat="server" EnableKeyboardNavigation="true"
                                    CausesValidation="false">
                                </Calendar>
                            </:DatePicker>
                            <div class="vldx">
                                <asp:RequiredFieldValidator runat="server" ID="rfvSupplierOnLeaveEndDate" ControlToValidate="dpSupplierOnLeaveEndDate"
                                    class="errmsg" ValidationGroup="grpSupplierInformation" Display="Dynamic" ErrorMessage="SUPPLIER_ONLEAVE_END_DATE_MANDATORY" %>'
                                    Enabled="false" />
                                <asp:CompareValidator ID="cmpSupplierOnLeaveEndDate" ControlToValidate="dpSupplierOnLeaveEndDate"
                                    class="errmsg" ValidationGroup="grpSupplierInformation" Operator="GreaterThanEqual"
                                    Display="Dynamic" ControlToCompare="dpSupplierOnLeaveStartDate" Type="Date" runat="server"
                                    ErrorMessage="SUPPLIER_ONLEAVE_END_DATE_GRATER_THAN_ONLEAVE_START_DATE" %>'></asp:CompareValidator>
                            </div>
                        </div>
                        <div class='sxroend'>
                        </div>
                    </div>
                </div>


the condition is :Onleavestartdate should be greater than currentdate,and if user has entered Onleavestartdate he also has to enter OnLeaveEndDate which should be greater than OnLeavestartdate.
Everything is working fine ,the only problem is that if i enter onleavestartdate and then i plan not to enter the date since it is not a mandatory field,it is not being deselected.

Any help would be highly admired.
thanks in advance.
Posted
Updated 20-Nov-12 1:55am
v3

1 solution

By doing the following the code runs correctly:

C#
DateInput-ReadOnly="false"
EnableKeyboardNavigation="false"
 
Share this answer
 

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