ASPxClientParseDateEventArgs.value Property
Gets the value entered into the date editor by an end user.
#Declaration
value: string
#Property Value
Type | Description |
---|---|
string | The string value entered into the date editor by an end user. |
#Remarks
Use the value property to obtain the value entered by an end user. This string value can then be converted to an appropriate date/time value and assigned to the ASPxClientParseDateEventArgs.date property. The ASPxClientParseDateEventArgs.handled property must be set to true
to prevent the default conversion operation.
#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>