Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

ASP.NET: Clear all TextBox values

From Wiki

Jump to: navigation, search

Summary: An example of a recursive function to clear all TextBox values on a page

  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.     EmptyTextBoxValues(Me)
  3. End Sub
  4.  
  5. Private Sub EmptyTextBoxValues(ByVal parent As Control)
  6.     For Each c As Control In parent.Controls
  7.         If (c.Controls.Count > 0) Then
  8.             EmptyTextBoxValues(c)
  9.         Else
  10.             If TypeOf c Is TextBox Then
  11.                 CType(c, TextBox).Text = ""
  12.             End If
  13.         End If
  14.     Next
  15. End Sub


This Hack is part of the ASP.NET Hacks collection

436 Rating: 3.1/5 (54 votes cast)