Posts Simple code to loop through all the textboxes in your page
Post
Cancel

Simple code to loop through all the textboxes in your page

This is the simple code you can use, to loop through all the textboxes in your page. Not only textboxes you can change the textbox in

“(ctrl is Textbox)” to the control you’ll like to loop in your page.

private  void processTextbox()
{
     foreach (Control ctrl in Page.Controls)
     {
          if (ctrl is TextBox)
          {
              //do something here
          }
          else
          {
              //do something here
          }
     }
}

Njoy coding

This post is licensed under CC BY 4.0 by the author.