Clear all textbox data

D

Danial

Hi,

I am using asp.net 2 and i want to blank all textbox data of one form with
(for each control) and i write following coding in button control, but it
did not work.


Dim ctl As Control

For Each ctl In Me.Controls

If TypeOf ctl Is TextBox Then

CType(ctl, TextBox).Text = ""

End If

Next

if anyone have answer

thanks

Danial
 
W

Willem

The controls are nested. Write the id's of the controls you do find
into a label and you will see what I mean. They might be inside a form
or contentplaceholder. Mine are in a contentplaceholder called
"MainContent".

For Each ctl In Me.Form.Controls
If ctl.ID = "MainContent" Then 'or where-ever your controls
are
content = ctl
End If
Next

For Each ctl In content.Controls
If ctl.GetType() Is GetType(TextBox) Then
' do your thing here
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top