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

Use a loop check values in RadTextBox

2 Answers 150 Views
Input
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 04 May 2009, 06:55 PM
I created a contact form and I want to check the values for spam. 

The contactus.aspx page contains a bunch of RadTextBox within an HTML table.

<telerik:RadTextBox ID="txtFirstName" Runat="server" Label="First Name:"
Skin="WebBlue" Width="200px">
</telerik:RadTextBox>


The code behind for submit

 

 

using Telerik.Web.UI

 

 



protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //Spam check for url=
         foreach(Control c in this.Controls)
        {

            if (c is RadTextBox)
            {
                // Attempting to reset the text value to test, just for testing to see if I am touching the control
                 (c as Telerik.Web.UI.).Text = "test";
            }
        }

}

Is this the right way to loop the form for RadTextBox?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 May 2009, 07:08 AM

Hello David,

I tried your code and its working fine on my end (and you need to TypeCast the control to Telerik.Web.UI.RadTextBox in order to get reference to RadTextBox).

Here is my C# code:

 
protected void Button1_Click(object sender, EventArgs e)  
{  
    foreach(Control c in this.form1.Controls)  
    {  
        if (c is RadTextBox)  
        {  
            // Attempting to reset the text value to test, just for testing to see if I am touching the control  
             (c as Telerik.Web.UI.RadTextBox).Text = "Test";  
        }  
    }  

Thanks,
Princy.

0
David
Top achievements
Rank 1
answered on 05 May 2009, 12:10 PM
Thanks Princy, it is working perfect now.

David
Tags
Input
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or