473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Page.FindControl type casting

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
ma**********@NOSPAM.bytronic.com
Nov 19 '05 #1
2 1681
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
ma**********@NOSPAM.bytronic.com

Nov 19 '05 #2
Thanks, :-)
Works a treat!

--
Martin Eyles
ma**********@NOSPAM.bytronic.com

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:EA**********************************@microsof t.com...
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
ma**********@NOSPAM.bytronic.com

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
1
by: Samuel Chowdhuri | last post by:
this peace of code is giving me trouble DIM i as DataGridItem for each i in myDataGrid checkbox chkbox = Ctype(i.findcontrol("deletethis"),checkbox) if(chkbox.checked) then ...... .....
5
by: Howard | last post by:
i have a default.master and default.aspx in default.aspx i would like to access a variable in default.master pageTitle public partial class _Default : System.Web.UI.Page { protected void...
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
5
by: Paul | last post by:
I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
2
by: jaffar.kazi | last post by:
Hi, What is the exact name to use to get a control reference on an asp.net page using FindControl? My experience is the following: 1. Page.FindControl does not work; it always returns null, even...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.