for each webcontrol

T

tommy

hello,

i know how to set values for each control on my windows-form.
but how to do this in asp.net??

example for windows-forms:

dim txtBox as Textbox
dim myControl as Control

for each mycontrol in control

is typeof mycontrol is textbox then
txtbox.text = "Hello"
end if

next


for each mycontrol in webcontrol doesnt work

suggestions?


best regards

tommy
 
M

Mike Moore [MSFT]

Hi Tommy,

Please try the following:

Dim ctl As Control
For Each ctl In Page.Controls(1).Controls
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).Text = "hello"
End If
Next

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
T

thomas hauser

Hello Mike,

thank you very much- its work fine !!! :)



best regards from munich


tommy

----------------------------------------
HangulHanjaFastConversion-Eigenschaft

True if Microsoft Word automatically converts a word with
only one suggestion during conversion between hangul
and hanja. Read/write Boolean.
 
M

Maras

Hi Mike,
Dim ctl As Control
For Each ctl In Page.Controls(1).Controls
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).Text = "hello"
End If
Next

Could you explain me why the index is 1 (Page.Controls(1).Controls) and not
for example 0 ?

Thanks a lot,
cheers
 
M

Mike Moore [MSFT]

Hi Maras,

Control(0) is the header. Control(1) is the form. All the web controls are
in the form.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top