-1

I got 2 DateEDit controls in my webform: StartDate and EndDate I want to validate that when EndDate changes, it won't be an earlier date than the StartDate. Also I want to validate that when the StartDate changes, the EndDate resets with StartDate's value + 1 day.

I managed to do this activating AutoPostBack, but doesn't seem so well... and without it the event DateChanged doesn't trigger.

       <td><dx:ASPxLabel ID="lbl_StarDate" runat="server" Text="Start Date:" Font-Bold="True" Visible="True">
            </dx:ASPxLabel></td>
       <td><dx:ASPxDateEdit ID="de_StartDate" runat="server" Height="19px" Width="240px"></dx:ASPxDateEdit></td>
     </tr>
     <tr>
       <td><dx:ASPxLabel ID="lbl_EndDate" runat="server" Text="End Date:" Font-Bold="True" Visible="True">
            </dx:ASPxLabel></td>
       <td><dx:ASPxDateEdit ID="de_EndDate" runat="server" Height="17px" Width="220px"></dx:ASPxDateEdit></td>

Can you please help me on this?

Xanathos
  • 598
  • 3
  • 15
  • 31

2 Answers2

1

This can all be done in javascript. To trigger the javascript events, change your aspx to the following:

    <tr>
        <td>
            <dx:ASPxLabel ID="lbl_StarDate" runat="server" Text="Start Date:" Font-Bold="True"
                Visible="True" />
        </td>
        <td>
            <dx:ASPxDateEdit ID="de_StartDate" ClientInstanceName="de_StartDate" runat="server"
                Height="19px" Width="240px">
                <ClientSideEvents ValueChanged="OnStartDateChanged" />
            </dx:ASPxDateEdit>
        </td>
    </tr>
    <tr>
        <td>
            <dx:ASPxLabel ID="lbl_EndDate" runat="server" Text="End Date:" Font-Bold="True" Visible="True" />
        </td>
        <td>
            <dx:ASPxDateEdit ID="de_EndDate" runat="server" Height="17px" Width="220px">
                <ClientSideEvents ValueChanged="OnEndDateChanged" />
            </dx:ASPxDateEdit>
        </td>
    </tr>    

Then handle the javascript in the respective methods:

<script type="text/javascript">

    function OnStartDateChanged(s, e) {
       //code here
    }

    function OnEndDateChanged(s, e) {
        //code here
    }

</script>
Jason
  • 1,226
  • 12
  • 23
0

You should use

de_Endate.minDate=de_StartDate.date;

in the de_startDate's change event

For more info check the documnetation

http://documentation.devexpress.com/#AspNet/DevExpressWebASPxEditorsASPxDateEdit_MinDatetopic

Guruparan
  • 71
  • 1
  • 8