Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page.FindControl type casting

Reply
Thread Tools

Page.FindControl type casting

 
 
Martin Eyles
Guest
Posts: n/a
 
      09-15-2005
Hi,

I am using Page.FindControl in a loop to select some numbered tags

aTag = Page.FindControl("Tick_" + CStr(aNumber))

however, when I come to add a style to this

aTag.Style.Add("visibility", "visible")

I can't, because aTag is too general a type of object. I need to cast it
back the the type that it actually is (an HTML control, rather than a plain
control).

How would I do this?

Thanks,
ME

--
Martin Eyles
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      09-15-2005
Cast it:

Dim MyObject as HTMLControl = Ctype(aType, HTMLControl)
MyObject.Style.Add("visibility", "visible")


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


"Martin Eyles" wrote:

> Hi,
>
> I am using Page.FindControl in a loop to select some numbered tags
>
> aTag = Page.FindControl("Tick_" + CStr(aNumber))
>
> however, when I come to add a style to this
>
> aTag.Style.Add("visibility", "visible")
>
> I can't, because aTag is too general a type of object. I need to cast it
> back the the type that it actually is (an HTML control, rather than a plain
> control).
>
> How would I do this?
>
> Thanks,
> ME
>
> --
> Martin Eyles
> (E-Mail Removed)
>
>
>

 
Reply With Quote
 
 
 
 
Martin Eyles
Guest
Posts: n/a
 
      09-15-2005
Thanks,
Works a treat!

--
Martin Eyles
(E-Mail Removed)

"Cowboy (Gregory A. Beamer) - MVP" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> Cast it:
>
> Dim MyObject as HTMLControl = Ctype(aType, HTMLControl)
> MyObject.Style.Add("visibility", "visible")
>
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Martin Eyles" wrote:
>
> > Hi,
> >
> > I am using Page.FindControl in a loop to select some numbered tags
> >
> > aTag = Page.FindControl("Tick_" + CStr(aNumber))
> >
> > however, when I come to add a style to this
> >
> > aTag.Style.Add("visibility", "visible")
> >
> > I can't, because aTag is too general a type of object. I need to cast it
> > back the the type that it actually is (an HTML control, rather than a

plain
> > control).
> >
> > How would I do this?
> >
> > Thanks,
> > ME
> >
> > --
> > Martin Eyles
> > (E-Mail Removed)
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
casting primitive type to user-defined type works in usage xllx.relient.xllx@gmail.com C++ 2 04-15-2006 05:37 AM
type casting vs. type converting Toby VHDL 3 09-07-2005 01:42 PM
Re: Type casting- a larger type to a smaller type pete C Programming 4 04-02-2004 05:19 PM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM
Casting between const type** and type** Kevin L C++ 6 08-11-2003 03:39 PM



Advertisments