Ask a Question related to ASP.NET General, Design and Development.
-
-
HtmlTextWriterStyle enumeration does not contain most of the available CSS properties
I was using the HtmlTextWriter class, and I noticed that the HtmlTextWriterStyle enumeration contains very few of the available CSS properties. The... -
help with UserControl and enumeration in VB.NET
Hello all, I've got limited experience with VB.NET, so please bear with me... I have a user control that has an Enumeration, "renderMode" which... -
Enumeration in Component
I am using C# in Visual Studio to develop my own component. I inherited from System.ComponentModel.Component. I added a public variable that is a... -
Databinding to a collection with a enumeration property
I have a class that has properties; "value","description" and "type". The first two are string properties, but "type" is a enum type. I create the... -
files enumeration
Hi All, I tried to enumated all files under a specific directory (folder) by first calling MoreFilesX's FSGetDirectoryItems() then I use... -
John Timney \(Microsoft MVP\) #2
Re: WebControls enumeration
try something like this
foreach (Control c in this.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebC ontrols.TextBox")
{
// ...do something...
}
}
--
Regards
John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------
"Vik" <viktorum@==yahoo.com==> wrote in message
news:OQriV2kRDHA.1720@TK2MSFTNGP10.phx.gbl...> Is there enumeration for the WebControls?
>
> Thanks.
>
>
John Timney \(Microsoft MVP\) Guest
-
Mark Friedman #3
Re: WebControls enumeration
If you're using VB try this:
For Each (Control c in Controls)
if TypeOf c is System.Web.UI.WebControl Then
// ...do something...
Next
-Mark
"John Timney (Microsoft MVP)" <xyztimneyj@btinternet.com> wrote in message
news:OeDr3LlRDHA.1804@TK2MSFTNGP11.phx.gbl...> try something like this
>
> foreach (Control c in this.Controls)
> {
> if (c.GetType().ToString().Equals("System.Web.UI.WebC ontrols.TextBox")
> {
> // ...do something...
> }
> }
>
>
>
> --
> Regards
>
> John Timney (Microsoft ASP.NET MVP)
> ----------------------------------------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> ----------------------------------------------
>
> "Vik" <viktorum@==yahoo.com==> wrote in message
> news:OQriV2kRDHA.1720@TK2MSFTNGP10.phx.gbl...>> > Is there enumeration for the WebControls?
> >
> > Thanks.
> >
> >
>
Mark Friedman Guest
-
bruce barker #4
Re: WebControls enumeration
actually you need to recurse, or you will miss controls in usercontrols,
grids, etc.
walkControls(this.Controls);
void walkControls (Control c)
{
foreach (Control child in this.Controls)
{
walkControl(child);
if
(child.GetType().ToString().Equals("System.Web.UI. WebControls.TextBox")
{
// ...do something...
}
}
}
}
"John Timney (Microsoft MVP)" <xyztimneyj@btinternet.com> wrote in message
news:OeDr3LlRDHA.1804@TK2MSFTNGP11.phx.gbl...> try something like this
>
> foreach (Control c in this.Controls)
> {
> if (c.GetType().ToString().Equals("System.Web.UI.WebC ontrols.TextBox")
> {
> // ...do something...
> }
> }
>
>
>
> --
> Regards
>
> John Timney (Microsoft ASP.NET MVP)
> ----------------------------------------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> ----------------------------------------------
>
> "Vik" <viktorum@==yahoo.com==> wrote in message
> news:OQriV2kRDHA.1720@TK2MSFTNGP10.phx.gbl...>> > Is there enumeration for the WebControls?
> >
> > Thanks.
> >
> >
>
bruce barker Guest
-
Vik #5
Re: WebControls enumeration
Thanks everybody.
Originally I had code like this which worked fine:
CtlType = ctl.GetType.Name
Select Case CtlType
Case "TextBox"
....
Case "Label"
....
End Select
I changed it to:
If TypeOf ctl Is TextBox Then
....
ElseIf TypeOf ctl Is Label Then
....
End If
This code does not work because TypeOf ctl Is Label = True for example when
CtlType="CompareValidator".
Vik
"Ben" <mustbejoking@120spamsaday.con> wrote in message
news:uHe%23xAnRDHA.2676@TK2MSFTNGP10.phx.gbl..."is",> ToString.Equals() or == is not very type safe, great for displaying to a
> console or output file but in code you should really use "typeof" andis> after all the code knows these types already and you verify that the code(c.GetType().ToString().Equals("System.Web.UI.WebC ontrols.TextBox")> correct at compile time. You need to itterate though the tree of controls
> too as mentioned.
>
> Ben W
>
>
> "John Timney (Microsoft MVP)" <xyztimneyj@btinternet.com> wrote in message
> news:OeDr3LlRDHA.1804@TK2MSFTNGP11.phx.gbl...> > try something like this
> >
> > foreach (Control c in this.Controls)
> > {
> > if>> > {
> > // ...do something...
> > }
> > }
> >
> >
> >
> > --
> > Regards
> >
> > John Timney (Microsoft ASP.NET MVP)
> > ----------------------------------------------
> > <shameless_author_plug>
> > Professional .NET for Java Developers with C#
> > ISBN:1-861007-91-4
> > Professional Windows Forms
> > ISBN: 1861005547
> > Professional JSP 2nd Edition
> > ISBN: 1861004958
> > Professional JSP
> > ISBN: 1861003625
> > Beginning JSP Web Development
> > ISBN: 1861002092
> > </shameless_author_plug>
> > ----------------------------------------------
> >
> > "Vik" <viktorum@==yahoo.com==> wrote in message
> > news:OQriV2kRDHA.1720@TK2MSFTNGP10.phx.gbl...> >> > > Is there enumeration for the WebControls?
> > >
> > > Thanks.
> > >
> > >
> >
>
Vik Guest



Reply With Quote

