NumericTextBox - Get Masked Text

6 posts, 0 answers
  1. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 17 Sep 2013 Link to this post

    Hi,
    How can I get the masked text from a RadNumericTextBox?
    For example...

    // RadTextBox
    RadNumericTextBox rntb = new RadNumericTextBox();
    rntb.NumberFormat.PositivePattern = "n%";
    rntb.NumberFormat.DecimalDigits = 0;
    rntb.MinValue = 0;
    rntb.MaxValue = 100;
    rntb.Text = 50; // Displays as "50%"
     
    // How do I get "50%" into a label?
    Label lbl = new Label();
    lbl.Text = rntb.Text; // Only shows "50". I want to show "50%"

    In the above example, how can I get the masked value "50%"?
    TextWithLiterals would be great but only applies to RadMaskedTextBox. 

    Thanks!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Sep 2013 Link to this post

    Hi Joe,

    The rntb.Text property always returns the text without the positive/negative pattern. Please have a look at the sample code I tried to extract the pattern which works fine at my end.

    C#:
    string pattern = rntb.NumberFormat.PositivePattern;
    Label1.Text = rntb.Text + pattern[pattern.Length - 1];

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 18 Sep 2013 Link to this post

    Perfect. Thanks Shinu!
  5. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 18 Sep 2013 Link to this post

    One related question...
    That code works for a suffix such as the "%" symbol. How can I achieve the same effect for a prefix like "$" symbol?

    For a prefix, the above code converts "$50" to "50n".

    Thanks again!
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Sep 2013 Link to this post

    Hi Joe,

    Please check the following C# code.

    C#:
    rntb.NumberFormat.PositivePattern = "$n";

    string pattern = rntb.NumberFormat.PositivePattern;
    Label1.Text = pattern[0] + rntb.Text;

    Thanks,
    Shinu
  7. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 19 Sep 2013 Link to this post

    Thanks again Shinu
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017