RadMaskedEditBox

12 posts, 0 answers
  1. JOSE MANUEL PÉREZ RAMÍREZ
    JOSE MANUEL PÉREZ RAMÍREZ avatar
    22 posts
    Member since:
    Jan 2008

    Posted 23 Jun 2009 Link to this post

    i have one RadMaskedEdit bind to object, with date mask.
    My object sets a value in radMasked and if i want to clear or set to null then radmasked does not clear.
    the control does not set to empty.
    how i do?

  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 26 Jun 2009 Link to this post

    Hi JOSE MANUEL PÉREZ RAMÍREZ,

    Thank you for writing. 

    I am not sure that I fully understand your scenario. If you want to set a null value from RadMaskedEditBox to the data structure, RadMaskedEditBox does not currently support it. However, you can implement such option with using a Clear button for example.

    Do not hesitate to contact me again if you have other questions

    Best wishes,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    2 posts
    Member since:
    Nov 2013

    Posted 31 Mar 2015 in reply to Martin Vasilev Link to this post

    Is there still no way to Clear a value from a RadMaskedEdit Editor after it has been set, even with 2015 Q1 Version of the controls. We find that if you clear the box, on Postback it still has the value and submits that to the database.
  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 03 Apr 2015 Link to this post

    Hi Robert,

    Thank you for writing.

    This is the UI For Winforms forum, I believe that your question has already been answered in the support ticket you have opened at Telerik UI for ASP.NET AJAX

    Should you have questions considering our suite do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Sergio
    Sergio avatar
    3 posts
    Member since:
    Dec 2013

    Posted 19 Jul 2015 Link to this post

    I´am searching for the same solution for a long time, and it seem to me the most basic thing for one control. Setting it to empty.

    When you clear the form for the next record or a new one, who do one clear the fields?

    As incredibel as it seem to be the most dificul thing to do.  If You set 'value' to '' does noithing. If you set 'text' to '', well it sems to work, but only changes the display. Even if You use clear still doesn't work.

    Please advise. 

     

  7. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 22 Jul 2015 Link to this post

    Hello Sergio,

    Thank you for writing.

    We have a similar issue which has been fixed in 2013, please check the feedback item which also suggests a workaround. With newer assemblies, I am unable to reproduce the incorrect behavior, setting RadMaskedEditBox.Value to null clears the text box.

    If you are still experiencing issues please provide me with detailed information how I can reproduce the behavior on your end and also please specify what version of the suite you are using.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik

  8. Adam P
    Adam P avatar
    27 posts
    Member since:
    Jan 2014

    Posted 23 Aug 2015 in reply to Hristo Merdjanov Link to this post

    Hello, the fact that the Clear method doesn't work and setting the Value or Text props to "" doesn't work has cost me several hours of work.  

    When the form initializes, the RadMaskedEditBox control initializes with a blank "" value, not a null value.  But to clear it, you have to set it to null, and the Clear() method (which the docs say clears the text from the control) seems useless.  This is a very unintuitive API.

    In order to reset the Value properly (to the initialized value of a blank string), you must call:

    radMaskedEditBox2.Value = null;
    radMaskedEditBox2.Value = string.Empty;

    The source code for the control shows that Clear simply sets Text to "(string)null" which seems to get immediately reset to the stored underlying Value very easily (like refocusing the control).  It seems as if the Clear method should set the Value to null instead (which would cause the Text to get set, too).

    The Value getter has several conditions based on the different TextMaskFormat but all that gets overriden if "isNullValue" equals true (which seems to get set to false by simple things like key presses, regardless of the key).

    Note, these issues are seen in 2014.3.1202.40.  I can't confirm if newer versions have these problems.

    Here is some sample code:

    Designer:

    //
    // radMaskedEditBox2
    //
    this.radMaskedEditBox2.Location = new System.Drawing.Point(12, 12);
    this.radMaskedEditBox2.Mask = "000-00-0000";
    this.radMaskedEditBox2.MaskType = Telerik.WinControls.UI.MaskType.Standard;
    this.radMaskedEditBox2.Name = "radMaskedEditBox2";
    this.radMaskedEditBox2.Size = new System.Drawing.Size(156, 24);
    this.radMaskedEditBox2.TabIndex = 0;
    this.radMaskedEditBox2.TabStop = false;
    this.radMaskedEditBox2.Text = "___-__-____";
    this.radMaskedEditBox2.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;

    Code:

    private void ClearAttempt1()
    {
        Debug.WriteLine("Attempt 1");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Clear();
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }
     
    private void ClearAttempt2()
    {
        Debug.WriteLine("Attempt 2");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = string.Empty;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }
     
    private void ClearAttempt3()
    {
        Debug.WriteLine("Attempt 3");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Text = "___-__-____";
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }
     
    private void ClearAttempt4()
    {
        Debug.WriteLine("Attempt 4");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = null;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = string.Empty;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }

    Results (only Attempt 4 succeeds at setting null and then blank):

    Attempt 1
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: , Value: 122442222, Mask: 000-00-0000
    Attempt 2
    Text: , Value: 122442222, Mask: 000-00-0000
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Attempt 3
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Attempt 4
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: ___-__-____, Value: [NULL], Mask: 000-00-0000
    Text: ___-__-____, Value: , Mask: 000-00-0000

  9. Adam P
    Adam P avatar
    27 posts
    Member since:
    Jan 2014

    Posted 23 Aug 2015 in reply to Hristo Merdjanov Link to this post

    Hello, the fact that the Clear method doesn't work and setting the Value or Text props to "" doesn't work has cost me several hours of work.  
    When the form initializes, the RadMaskedEditBox control initializes with a blank "" value, not a null value.  But to clear it, you have to set it to null, and the Clear() method (which the docs say clears the text from the control) seems useless.  This is a very unintuitive API.
    In order to reset the Value properly (to the initialized value of a blank string), you must call:

    radMaskedEditBox2.Value = null;
    radMaskedEditBox2.Value = string.Empty;

    The source code for the control shows that Clear simply sets Text to "(string)null" which seems to get immediately reset to the stored underlying Value very easily (like refocusing the control).  It seems as if the Clear method should set the Value to null instead (which would cause the Text to get set, too).
    The Value getter has several conditions based on the different TextMaskFormat but all that gets overriden if "isNullValue" equals true (which seems to get set to false by simple things like key presses, regardless of the key).
    Note, these issues are seen in 2014.3.1202.40.  I can't confirm if newer versions have these problems.
    Here is some sample code:
    Designer:

    //
    // radMaskedEditBox2
    //
    this.radMaskedEditBox2.Location = new System.Drawing.Point(12, 12);
    this.radMaskedEditBox2.Mask = "000-00-0000";
    this.radMaskedEditBox2.MaskType = Telerik.WinControls.UI.MaskType.Standard;
    this.radMaskedEditBox2.Name = "radMaskedEditBox2";
    this.radMaskedEditBox2.Size = new System.Drawing.Size(156, 24);
    this.radMaskedEditBox2.TabIndex = 0;
    this.radMaskedEditBox2.TabStop = false;
    this.radMaskedEditBox2.Text = "___-__-____";
    this.radMaskedEditBox2.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;

    Code:

    private void ClearAttempt1()
    {
        Debug.WriteLine("Attempt 1");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Clear();
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }

    private void ClearAttempt2()
    {
        Debug.WriteLine("Attempt 2");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = string.Empty;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }

    private void ClearAttempt3()
    {
        Debug.WriteLine("Attempt 3");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Text = "___-__-____";
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }

    private void ClearAttempt4()
    {
        Debug.WriteLine("Attempt 4");
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = null;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
        radMaskedEditBox2.Value = string.Empty;
        Debug.WriteLine("Text: {0}, Value: {1}, Mask: {2}", radMaskedEditBox2.Text ?? "[NULL]", radMaskedEditBox2.Value ?? "[NULL]", radMaskedEditBox2.Mask ?? "[NULL]");
    }

    Results (only Attempt 4 succeeds at setting null and then blank):

    Attempt 1
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: , Value: 122442222, Mask: 000-00-0000
    Attempt 2
    Text: , Value: 122442222, Mask: 000-00-0000
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Attempt 3
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Attempt 4
    Text: 122-44-2222, Value: 122442222, Mask: 000-00-0000
    Text: ___-__-____, Value: [NULL], Mask: 000-00-0000
    Text: ___-__-____, Value: , Mask: 000-00-0000
  10. Adam P
    Adam P avatar
    27 posts
    Member since:
    Jan 2014

    Posted 23 Aug 2015 in reply to Adam P Link to this post

    Sorry for the double posting, I got an error when I first submitted (but did a Select All + Copy before submitting) and reposted with my formatting lost lol
  11. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 26 Aug 2015 Link to this post

    Hi Adam,

    Thank you for writing.

    The Clear method is inherited from the TextBoxBase class and is only responsible for deleting the text in the editor and is not related with the Value property. Setting the value to an empty string would not work because the value would get validated and it will not pass the requirements of the current mask.

    With the latest version setting the Text property to its initial value sets produces the result you expect. If you stick with your current version as you have investigated you would need to use this approach:
    radMaskedEditBox2.Value = null;
    radMaskedEditBox2.Value = string.Empty;

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik

  12. Adam P
    Adam P avatar
    27 posts
    Member since:
    Jan 2014

    Posted 26 Aug 2015 in reply to Hristo Merdjanov Link to this post

    Thanks Hristo, that's good to know about the latest version.  Far more intuitive that way.  

    If I could make one more suggestion: when you override the TextBoxBase, perhaps override the Clear method to either hide it completely from intellisense or override the functionality to properly clear it.  It might want to be noted in the docs, too, since I read those and it seemed like the Clear method was the right way to do it.

  13. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 31 Aug 2015 Link to this post

    Hello Adam,

    Thank you for you suggestion.

    I cannot confirm that we will add an overridden implementation of the Clear method, but  for sure we will think of a better explanation in our documentation.

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik

Back to Top
UI for WinForms is Visual Studio 2017 Ready