Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

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: 4.3/5 (3 votes cast)