Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
For each control
Message
From
24/10/2007 15:48:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/10/2007 09:25:30
Joel Casse
Bishops University
Lennoxville, Quebec, Canada
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01263033
Message ID:
01263324
Views:
8
>Bonjour!
>
>I woould like create a function to save all the fields(control) on my web page to a text file or database. In VB6 we could say something like for each control etc..
>if type textbox then....
>Can we do the same with VB.NET??
>
>Thanks Joel :)

Yes you can. From VS help "How to: Locate the Web Forms Controls on a Page by Walking the Controls Collection" topic:
"...A more practical application of walking the controls this way would be to create a recursive method that can be called to walk the Controls collection of each control as it is encountered. However, for clarity, the example below is not created as a recursive function. "
Private Sub Button1_Click(ByVal sender As System.Object, _
 ByVal e As System.EventArgs) Handles Button1.Click
    Dim allTextBoxValues As String = ""
    Dim c As Control
    Dim childc As Control
    For Each c In Page.Controls
        For Each childc In c.Controls
            If TypeOf childc Is TextBox Then
                allTextBoxValues &= CType(childc, TextBox).Text & ","
            End If
        Next
    Next
    If allTextBoxValues <> "" Then
        Label1.Text = allTextBoxValues
    End If
End Sub
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform