RadMaskedTextBox missing 'MaskType' property

6 posts, 0 answers
  1. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 14 Aug 2011 Link to this post

    Hi

    I am trying to use the RadMaskedTextBox for the first time and have hit an issue. Where is the MaskType property?

    RadMaskedTextBox m1 = new RadMaskedTextBox();
    m1.ID = ID;
    m1.Mask = "d";
    //m1.MaskType  << No such property
    c2.Controls.Add(m1);

    (where c2 is a TableCell() control)

    Yet it is clearly documented on this page as a property of the RadMaskedTextBox

    http://www.telerik.com/help/wpf/radmaskedtextbox-features-numeric-mask.html

    Here is a sample of the code from that page.
    <telerik:RadMaskedTextBox MaskType="Numeric" Mask="d" Value="111.234" Margin="0,5,0,10" />

    How do I set the MaskType on a dynamically created RadMaskedTextbox?

    Note: I tried this

    m1.Attributes.Add("MaskType", "Numeric");

    Ugly and heavy handed way to do something that should be a property of the control. Does not work however.

    To make matters worse, the textbox that gets written to the page has the letter 'd' in it, AND it cannot be edited..

    The textbox input is disabled.

    What's going on?

    How do I add a dynamically created RadMaskedTextBox to a page, set it's MaskType property and have a functioning textbox once the page loads?








  2. Brad
    Brad avatar
    93 posts
    Member since:
    Jan 2011

    Posted 14 Aug 2011 Link to this post

    My bad.. The help I was looking at on the Telerik site is for RadControls for WPF. I'm using the ajax controls.

    Still, I could use some pointers for getting this control working.
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Aug 2011 Link to this post

    Hello Brad,

    You can achieve this by setting the Mask property for RadNumericTextBox as shown below.
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
     RadMaskedTextBox maskedBox = new RadMaskedTextBox();
     maskedBox.ID = "RadMaskedTextBox1";
     maskedBox.Mask = "(###)- ####";
    }

    Also check the following help documentation which explains more about this.
    RadmaskedTextBox Basics.

    Thanks,
    Princy.
  4. satish
    satish avatar
    3 posts
    Member since:
    Jan 2012

    Posted 22 Aug 2013 Link to this post


    Hello Princy,

    I have added radmaskedtextbox dynamically using code given below. Control is added successfully but mask property was not working. Radmaskedtextbox is behaving like normal text box.

     var maskedTextBox = new RadMaskedTextBox();
     maskedTextBox.ID = "Textbox_Date";
     maskedTextBox.Mask = "##/##/####";
      Page.Controls.Add(maskedTextBox);


    Please help me.

    Thanks in advance.

    Thanks and best regards,
    satish
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2013 Link to this post

    Hi satish,

    Please have a look into the following code I tried which works fine at my end.

    C#:
    RadMaskedTextBox RadMaskedTextBox1 = new RadMaskedTextBox();
    RadMaskedTextBox1.Mask = "##/##/####";
    this.form1.Controls.Add(RadMaskedTextBox1);

    Thanks,
    Shinu.
  6. satish
    satish avatar
    3 posts
    Member since:
    Jan 2012

    Posted 23 Aug 2013 Link to this post


    Hi Shinu,

    It is working fine. Thank you so much.

    Thanks and best regards,
    Satish
Back to Top