This is a migrated thread and some comments may be shown as answers.

RadDatePicker: How to pass invalid date to server for validation

1 Answer 263 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Shubh
Top achievements
Rank 1
Shubh asked on 27 May 2014, 12:19 PM
Previous Question

I am trying to validate date in server side. When I am trying to pass invalid date to my server side code, it is getting converted to {01/01/0001 00:00:00}.

Works fine when I select proper date.

Here is my code:

<telerik:RadDatePicker ID="rdpDob" runat="server" AutoPostBack="true"   DateInput-EmptyMessage="MaxDate" MinDate="01/01/1000"MaxDate="01/01/3000">

When I try to access the date value:
rdpDob.SelectedDate

It is returning as null.

Which is quiet strange as I can see my invalid date being passed in the POST request.

Whats wrong with what I am doing, Is there any property which I need to tweek??

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 28 May 2014, 09:12 AM
Hi Shubh,

InValidDate will not be available after postback. One suggestion is that you can use the InvalidTextBoxValue  property. Please have a look into the sample code snippet.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" MinDate="01/01/2014">
</telerik:RadDatePicker>
<telerik:RadButton ID="RadButton1" runat="server" Text="Validate" OnClick="RadButton1_Click">
</telerik:RadButton>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    string value=RadDatePicker1.DateInput.InvalidTextBoxValue;
    if (value != string.Empty)
    {
        //your code for validation
    }
}

Thanks,
Shinu.
Tags
Calendar
Asked by
Shubh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or