Home All Groups Group Topic Archive Search About
Author
25 May 2005 6:14 PM
TR
I have an asp:Panel that contains a variety of controls, including
checkboxes and HtmlGenericControls. I can find the panel in codebehind using
FindControl(id), but then I want to either:

a) iterate all of the controls in the panel's Controls collection and, if
the control is a checkbox ..., or
b) find only the checkboxes in the panel and iterate through them

Using approach a) how do I determine if the current control is a checkbox?

Dim Crtl as System.Web.UI.Control
For Each Ctrl in MyPanel.Controls
If Ctrl ....


Is b) possible server-side? Is there a Find By Control Type?

Thanks for the help.
TR

Author
25 May 2005 6:24 PM
Axel Dahmen
Dim Crtl as System.Web.UI.Control
For Each Ctrl in MyPanel.Controls
  If TypeOf Ctrl Is CheckBox Then


HTH,
Axel Dahmen
Author
25 May 2005 7:32 PM
TR
Thanks, Axel. Perhaps you could help with another related question? If I
wanted to create a *generic* class to look for all instances of a specified
type of control in a given container, how would I specify the type?  Given
the following signature, how would the blank be filled in, in the If
TypeOf... line?  Is there a function that takes a string name for a type and
returns an object that makes sense to TypeOf ...?

Public Sub FindType(ByVal MyContainer as System.Web.UI.Control, ByVal mytype
as String)
    Dim Ctrl as System.Web.UI.Control
    For Each Ctrl in MyContainer.Controls
        If TypeOf Ctrl is ___________  Then
        ...
        End If
    Next
End Sub

Thanks again.
TR




Show quoteHide quote
"Axel Dahmen" <NO_SPAM@NoOneKnows.invalid> wrote in message
news:uv0NTcVYFHA.3864@TK2MSFTNGP10.phx.gbl...
> Dim Crtl as System.Web.UI.Control
> For Each Ctrl in MyPanel.Controls
>   If TypeOf Ctrl Is CheckBox Then
>
>
> HTH,
> Axel Dahmen
>
>
Author
26 May 2005 11:17 PM
Axel Dahmen
Hi, TR,

Schau mal unter "Type-Klasse" bzw. "Type class" in der MSDN-Hilfe. Mit der
Type-Klasse, z.B.:

Dim t As Type = GetType(Array)
If t.FullName = ....

oder

If t.GUID = ...

HTH,
Axel

------------
Show quoteHide quote
"TR" <T*@nowhere.biz> schrieb im Newsbeitrag
news:ufMd9BWYFHA.3220@TK2MSFTNGP14.phx.gbl...
> Thanks, Axel. Perhaps you could help with another related question? If I
> wanted to create a *generic* class to look for all instances of a
specified
> type of control in a given container, how would I specify the type?  Given
> the following signature, how would the blank be filled in, in the If
> TypeOf... line?  Is there a function that takes a string name for a type
and
> returns an object that makes sense to TypeOf ...?
>
> Public Sub FindType(ByVal MyContainer as System.Web.UI.Control, ByVal
mytype
> as String)
>     Dim Ctrl as System.Web.UI.Control
>     For Each Ctrl in MyContainer.Controls
>         If TypeOf Ctrl is ___________  Then
>         ...
>         End If
>     Next
> End Sub
>
> Thanks again.
> TR
>
>
>
>
> "Axel Dahmen" <NO_SPAM@NoOneKnows.invalid> wrote in message
> news:uv0NTcVYFHA.3864@TK2MSFTNGP10.phx.gbl...
> > Dim Crtl as System.Web.UI.Control
> > For Each Ctrl in MyPanel.Controls
> >   If TypeOf Ctrl Is CheckBox Then
> >
> >
> > HTH,
> > Axel Dahmen
> >
> >
>
>
Author
27 May 2005 8:31 PM
Timo
Danke sehr, Axel.


Show quoteHide quote
"Axel Dahmen" <NO_SPAM@NoOneKnows.invalid> wrote in message
news:OZK#SkkYFHA.3032@TK2MSFTNGP10.phx.gbl...
> Hi, TR,
>
> Schau mal unter "Type-Klasse" bzw. "Type class" in der MSDN-Hilfe. Mit der
> Type-Klasse, z.B.:
>
>  Dim t As Type = GetType(Array)
>  If t.FullName = ....
>
>  oder
>
>  If t.GUID = ...
>
> HTH,
> Axel
>
> ------------
> "TR" <T*@nowhere.biz> schrieb im Newsbeitrag
> news:ufMd9BWYFHA.3220@TK2MSFTNGP14.phx.gbl...
> > Thanks, Axel. Perhaps you could help with another related question? If I
> > wanted to create a *generic* class to look for all instances of a
> specified
> > type of control in a given container, how would I specify the type?
Given
> > the following signature, how would the blank be filled in, in the If
> > TypeOf... line?  Is there a function that takes a string name for a type
> and
> > returns an object that makes sense to TypeOf ...?
> >
> > Public Sub FindType(ByVal MyContainer as System.Web.UI.Control, ByVal
> mytype
> > as String)
> >     Dim Ctrl as System.Web.UI.Control
> >     For Each Ctrl in MyContainer.Controls
> >         If TypeOf Ctrl is ___________  Then
> >         ...
> >         End If
> >     Next
> > End Sub
> >
> > Thanks again.
> > TR
> >
> >
> >
> >
> > "Axel Dahmen" <NO_SPAM@NoOneKnows.invalid> wrote in message
> > news:uv0NTcVYFHA.3864@TK2MSFTNGP10.phx.gbl...
> > > Dim Crtl as System.Web.UI.Control
> > > For Each Ctrl in MyPanel.Controls
> > >   If TypeOf Ctrl Is CheckBox Then
> > >
> > >
> > > HTH,
> > > Axel Dahmen
> > >
> > >
> >
> >
>
>