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

Value of RadMaskedTextBox is reset.

3 Answers 242 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Jhun
Top achievements
Rank 1
Jhun asked on 03 Jun 2008, 03:26 AM
Hi,

Just want to ask if why the value of my RadMaskedTextBox is always reset to current date when ever I clicked or the cursor is on the said field.

Scenario is the RadMaskedTextBox is populated during the Load_Form event and whenever I click or put the cursor on the said field, it would reset the value to current day. Example is when the loaded data is 04/04/1980, and when I click or put the cursor on the said field, it would reset to current date, which is 06/03/2008.

Hoping for your swift reply.

Regards,
Jhun

3 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 06 Jun 2008, 07:59 AM
Hi Jhun,

I wasn't able to reproduce the behavior you have described. 

I have tried the following:
  1. Set the MaskType of the mask box to DateTime.
  2. Then, set the value to a DateTime value - 1980, 4, 4. 
  3. Run the application, and the value is 1980, 4, 4 even after I click in the text editing field.
Here is the code I'm using:
this.radMaskedEditBox1.Value = new DateTime(1980, 4, 4);

Could you please give me step-by-step instructions or attach a small project demonstrating the issue you are experiencing?

I'm looking forward to your response.

Best wishes,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jhun
Top achievements
Rank 1
answered on 10 Jun 2008, 12:59 AM
Hi Boyko,

I've tried the solution you said and it works. Thanks for the solution you gave me. Actually, what I'm using at the code was the following:

this.radMaskedEditBox1.Text = Convert.ToDateTime(cItem.BirthDate.ToString()).ToString("MM/dd/yyyy");

wherein the value of cItem.BirthDate was coming from a database with a DateTime declaration that accepts null value.

The only problem is when the value of datetime retrieved is null, how can I set it to null in the radMaskedEditBox1? Should I use radMaskedEditBox1.Value = null or radMaskedEditBox1.Text = null?

Regards,
Jhun
0
Boyko Markov
Telerik team
answered on 13 Jun 2008, 08:28 AM
Hi Jhun,

Thank you for writing.

In order to handle null values in the RadMaskedEditBox, it is more appropriate to use the Value property than the Text property. However, this control does not have built-in support of null values - setting the Value property or the Text to null will lead to unexpected behavior.

A control that is more suitable for your scenario is RadDateTimePicker control. RadDateTimePicker is the control used for handling dates using calendar, spin editing behavior and built-in mask box. RadDateTimePicker offers all the capabilities of the RadMaskedEditBox in scenarios where dates are handled. It offers full null date support, including cases where you receive a null value from the database. It adds additional features, including parsing of various date time formats.

Finally, if you want to have an appearance like that of the RadMaskedEditBox, you can achieve it by hiding the drop down.

If you need additional information, please contact us again.

Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TextBox
Asked by
Jhun
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Jhun
Top achievements
Rank 1
Share this question
or