Findcontrol problem

A

Arjen

Hi,

I have this inside my asp.net 2.0 page:

Page start code...

<asp:Content ID="content" ContentPlaceHolderID="content1" Runat="Server">
<table>
<tr>
<td id="mytd" runat="server">

... page end code.

How can I get mytd?

I tried this Page.FindControl("mytd") but this did not work. ;-(

Hope someone can help.
 
K

Kevin Spencer

The FindControl Method works only on the Controls that are immediately
inside the Control Specified. Example:

HtmlTableCell myTd = content1.FindControl("myTd");

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
S

Scott Allen

I tried this Page.FindControl("mytd") but this did not work. ;-(

Kevin gave you the correct answer. I have an article that expands on
the "why" part:

In Search Of ASP.NET Controls
http://odetocode.com/Articles/116.aspx

You are using master pages, and master pages are marked with the
INamingContainer interface. The article explains the impact of
INamingContainer on FindControl.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top