Is it possible to set the value of the MaskedText control programmatically?

4 posts, 0 answers
  1. Louis
    Louis avatar
    16 posts
    Member since:
    Feb 2011

    Posted 31 Mar 2011 Link to this post

    I'm trying to  create and populate a RadMaskedTextBox control within a Silverlight Project using the following code as an example.  However, Stepping through the code, the value of .MaskedText is nothing when it gets to the point of setting the variable Result.  Is it possible to set the RadMaskedTextBox control in code and if so what is the proper way to do it?
    Thanks
    Dim Result As String = "92881-0706"
    Dim PostMask As String = "#####-####'
    Dim mtb As New Telerik.Windows.Controls.RadMaskedTextBox
      
            If PostMask IsNot Nothing Then
                If PostMask.ToString.Length > 0 Then
                    With mtb
                        .MaskType = Telerik.Windows.Controls.MaskType.Standard
                        .Mask = PostMask
                        .Value = PostalCode
                        Result = .MaskedText
                    End With
      
                End If
            End If
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 06 Apr 2011 Link to this post

    Hello Louis,

    I cannot see where you have defined the "PostalCode" variable. Trying your code with "PostalCode" replaced with a sample string value works fine.

    All the best,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Louis
    Louis avatar
    16 posts
    Member since:
    Feb 2011

    Posted 06 Apr 2011 Link to this post

    Well testing again and stepping through the code .MaskedText is always Nothing.  

    Here's a simple code snippet which should duplicate the issue in a Silverlight 4 application:
     
    Dim Result As String = ""
    Dim PostMask As String = "#####-####'  
    Dim PostalCode = "02124"
    Dim mtb As New Telerik.Windows.Controls.RadMaskedTextBox  
          
            If PostMask IsNot Nothing Then
                If PostMask.ToString.Length > 0 Then
                    With mtb  
                        .MaskType = Telerik.Windows.Controls.MaskType.Standard  
                        .Mask = PostMask  
                        .Value = PostalCode  
                        Result = .MaskedText  
                    End With
          
                End If
            End If
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 12 Apr 2011 Link to this post

    Hi Louis,

    Unfortunately I am unable to reproduce your issue. Could you please examine my test project and let me know if I have missed something.

    Regards,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top