This is a migrated thread and some comments may be shown as answers.

How to Clear RadTextBoxes Using C#?

2 Answers 421 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
D.SRINIVASA
Top achievements
Rank 2
D.SRINIVASA asked on 14 Dec 2011, 01:43 PM
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 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 14 Dec 2011, 02:59 PM
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.
0
D.SRINIVASA
Top achievements
Rank 2
answered on 15 Dec 2011, 06:08 AM
HI Kevin,

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

Thanks
D.Srinivasa Rao
Tags
ComboBox
Asked by
D.SRINIVASA
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 2
D.SRINIVASA
Top achievements
Rank 2
Share this question
or