Use a loop check values in RadTextBox

3 posts, 0 answers
  1. David
    David avatar
    6 posts
    Member since:
    Dec 2008

    Posted 04 May 2009 Link to this post

    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. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 May 2009 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David  avatar
    35 posts
    Member since:
    Dec 2008

    Posted 05 May 2009 Link to this post

    Thanks Princy, it is working perfect now.

    David
Back to Top