RadMaskedTextBox Dynamicly Added Returning bad data

2 posts, 1 answers
  1. David
    David avatar
    19 posts
    Member since:
    Nov 2008

    Posted 05 May 2009 Link to this post

    If I add a RadMaskedTextBox with a mask like ###-## directly on the page, and the user enters 3__-22 I get "3  -22" returned.  However, if I add the control dynamicly through server-side code with the same settings, the returned value is "3".  Is there something special that has to be done when adding dynamicly?
  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 May 2009 Link to this post

    Hello David,

    I tried creating RadMaskedTextBox directly on page and also dynamically, both returns expected result and works fine. Here is my code.

    <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Mask="###-##">  
    <asp:Button ID="Button1" runat="server" Text="Get Values" OnClick="Button1_Click" /> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 

    RadMaskedTextBox textbox1 = new RadMaskedTextBox();  
    protected void Page_Init(object sender, EventArgs e)  
        textbox1.Mask = "###-##";  
        textbox1.ID = "RadMaskedTextBox2";  
    protected void Button1_Click(object sender, EventArgs e)  
        Label1.Text = RadMaskedTextBox1.TextWithLiterals;  
        Label2.Text = textbox1.TextWithLiterals;         
    Please feel to correct me if you are trying diffrent scenario.

  3. DevCraft R3 2016 release webinar banner
Back to Top