How to Clear RadTextBoxes Using C#?

3 posts, 0 answers
  1. D.SRINIVASA
    D.SRINIVASA avatar
    34 posts
    Member since:
    Oct 2010

    Posted 14 Dec 2011 Link to this post

    hi,
    i am D.Srinivasa Rao, i have a problem to Clear RadTextBox using c# in Asp.Net, in my page i have a number of RadTextBoxes and RadNumericTextBoxes. now i want to clear all RadTextBoxes, RadNumericTextBoxes  using control Functions.

    For TextBoxes i used the following Function to Clear all TextBoxes

    protected void ClearTextBoxes(Control control)
        {
            foreach (Control c in control.Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Text = "";
            }
        }


    in the same way how can i clear the RadTextBoxes. 

    Please Help me

    Thanks
    D.Srinivasa Rao.
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 14 Dec 2011 Link to this post

    Hello D.Srinivasa,

    To clear RadTextBox controls, it would be the same way as the TextBox control. For RadNumericTextBox you would set the Value property to null. Like so:

    protected void ClearTextBoxes(Control control)
        {
            foreach (Control c in control.Controls)
            {
                if (c is TextBox)
                {
                    ((TextBox)c).Text = "";
                }
                else if (c is RadTextBox)
                {
                   ((RadTextBox)c).Text = "";
                }
                else if (c is RadNumericTextBox)
                {
                   ((RadNumericTextBox)c).Value = null;
                }
            }
        }

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. D.SRINIVASA
    D.SRINIVASA avatar
    34 posts
    Member since:
    Oct 2010

    Posted 15 Dec 2011 Link to this post

    HI Kevin,

    thanks for Your reply, its works great.... 

    Thanks
    D.Srinivasa Rao
Back to Top