CLEAR FORM ELEMENTS/loop through page controls

Handy routine for clearing out all of your textbuttons or making all of your panels visible
 
Sub resetBtn_Click(Sender As Object, E As EventArgs)
Dim myForm As Control = Page.FindControl("myform") << put in name of your form on your page
Dim ctl As Control
For Each ctl In myForm.Controls
'Clears Textbox Types

  If ctl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox") Then
             CType(ctl, TextBox).Text = ""
  End If
 
Next ctl
End Sub

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax