PDA

View Full Version : [CLOSED] Text of DateField showing 1/1/0001



Ariel
Jun 09, 2014, 5:38 PM
Hi, I am using a DateField that works well when selecting from date selector but it is not returning anything when user enters free text.



<ext:DateField ID="CalcJobPricingDate" runat="server" Name="CalcJobPricingDate" HideMode="Display" AllowBlank="true" Hidden="true" />


(The control is hidden at first but then I unhide it when user clicks a button).

Anyways, this works:


CalcJobPricingDate.SelectedDate.ToShortDateString( )

But sometimes our user needs to enter a free text, in a different format, for example: 20140101 (YYYYMMDD format).
In those cases I just need the strong from "text" property.

When I check the text property I get 1/1/0001:


CalcJobPricingDate.Text

How can I make the DateField return what was entered in the text box in code behind?

Daniil
Jun 09, 2014, 6:47 PM
Hi @Ariel,

You can use

this.DateField1.RawText

As an alternative approach, you can register AltFormats for a DateField. There is a big set of default AltFormats.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date-cfg-altFormats

For "20140101" it should look like this.
Example

<ext:DateField ID="DateField1" runat="server" AltFormats="yyyyMMdd" />

Then you'll be able to use a DataField's SelectedDate.