Skip to main content
A newer version of this page is available. .

ASPxClientParseDateEventArgs.handled Property

Gets or sets a value specifying whether the event was handled.

Declaration

handled: boolean

Property Value

Type Description
boolean

true if the event was handled and default processing should not occur; false if the event should be handled using default processing.

Remarks

When handling an event the handled property should be set to true in the event’s handler to indicate that default processing is not required.

Example

This example demonstrates how the ParseDate event can be handled to resolve user input strings entered into the ASPxDateEdit.

After you type a predefined date constant (such as "today") or a simple expression (such as "today + 2") and press ENTER, the relevant date is automatically calculated and set to the editor.

<script type="text/javascript" language="javascript">

        function SmartParseDate(value){
            var dayDeltas = {
                "TODAY": 0, 
                "TOMMOROW": 1,
                "YESTERDAY": -1,
                "NOW": 0
            };
            var ret = null;

            if(_aspxIsExists(value)){
                var text = value.replace(/ /g,"");
                text = text.toUpperCase();

                for(var day in dayDeltas){
                    if(text.substr(0,day.length) == day){
                        text = text.substr(day.length);

                        var dayCount = parseInt(text);
                        if(isNaN(dayCount))
                            dayCount = 0;

                        var dateResult = new Date();
                        if(day != "NOW")
                            dateResult.setHours(0,0,0,0);
                        dateResult.setDate(dateResult.getDate() + dayCount + dayDeltas[day])
                        if(!isNaN(dateResult))
                            ret = dateResult;
                    }
                }
            }
            return ret;
        }

        function OnParseDate(editor, args){
            var date = SmartParseDate(args.value);
            if (date != null) {
                args.date = date;
                args.handled = true;
            }
        }

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <dxe:ASPxLabel ID="ASPxLabel1" runat="server" AssociatedControlID="ASPxDateEdit1"
            Text="Type a specific predefined word or expression (such as 'today + 1') within the date editor and press ENTER.">
        </dxe:ASPxLabel><dxe:aspxdateedit id="ASPxDateEdit1" runat="server" EditFormat="DateTime">
            <ClientSideEvents ParseDate="function (s, e){
                OnParseDate(s, e);
            } ">
            </ClientSideEvents>
    </dxe:aspxdateedit>
See Also