Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Clearing all field in a web form

This code shows you how to clear all field in a web form. It is very usefull in a page where there are a lot of text fields , check boxes which needs to be cleared with the press of a button


Private Sub ClearForm()
'Reset TextBoxes on form
Dim ctl As Control
For Each ctl In Me.FindControl("Form1").Controls
If (Not ctl Is System.DBNull.Value) Then
If (ctl.GetType.ToString().ToLower().IndexOf("textbox") > 0) Then
CType(ctl, TextBox).Text = String.Empty
End If
End If
Next

'Reset CheckBoxList
Dim i As Integer
While i < Me.chkType.Items.Count
Me.chkType.Items(i).Selected = False
i += 1
End While



End Sub


Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy