Password Textbox support similar to Android EditText

2 posts, 0 answers
  1. Srivatsa
    Srivatsa avatar
    1 posts
    Member since:
    Jun 2015

    Posted 03 Jun 2015 Link to this post


    Does RadControls have a textbox where in I can implement a textbox password field similar to Android Environment. 

    I should be able to enter a character, display the character entered for a few milliseconds before masking it using "asterix" or any other password

    character. Also I should be able to edit/insert/delete any character anywhere in the content.





  2. Dimitar
    Dimitar avatar
    2722 posts

    Posted 04 Jun 2015 Link to this post

    Hi Srivatsa,

    Thank you for writing.

    It is possible to achieve similar behavior with RadTextBoxControl. You can use a timer and replace the text with a password char after some time. You can save the password in a separate string and use the KeyDown and KeyPress events to synchronize the text. For example:
    Timer timer;
    string password;
    public RadForm1()
        password = "";
        timer = new Timer();
        timer.Tick += timer_Tick;
        timer.Interval = 800;
        radTextBoxControl1.TextChanged += radTextBoxControl1_TextChanged;
        radTextBoxControl1.KeyPress += radTextBoxControl1_KeyPress;
        radTextBoxControl1.KeyDown += radTextBoxControl1_KeyDown;
    void radTextBoxControl1_KeyDown(object sender, KeyEventArgs e)
        int caretIndex = radTextBoxControl1.CaretIndex;
        if (e.KeyCode == Keys.Back && caretIndex >= 0)
            password = password.Remove(caretIndex, 1);
    void radTextBoxControl1_KeyPress(object sender, KeyPressEventArgs e)
        int caretIndex = radTextBoxControl1.CaretIndex;
        if (char.IsLetterOrDigit(e.KeyChar))
            password = password.Insert(caretIndex, e.KeyChar.ToString());
        radLabel1.Text = password;
    void timer_Tick(object sender, EventArgs e)
        int caretIndex = radTextBoxControl1.CaretIndex;
        radTextBoxControl1.Text = new string('*', password.Length);
        radTextBoxControl1.CaretIndex = caretIndex ;
    void radTextBoxControl1_TextChanged(object sender, EventArgs e)
        if (timer.Enabled)

    Please let me know if there is something else I can help you with.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top