Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Findcontrol problem

Reply
Thread Tools

Findcontrol problem

 
 
Arjen
Guest
Posts: n/a
 
      10-17-2005
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.


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      10-17-2005
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.

"Arjen" <(E-Mail Removed)> wrote in message
news:dj0sqv$4fl$(E-Mail Removed)1.ov.home.nl...
> 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.
>
>



 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      10-18-2005
On Mon, 17 Oct 2005 21:08:24 +0200, "Arjen" <(E-Mail Removed)>
wrote:

>
>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,

--
Scott
http://www.OdeToCode.com/blogs/scott/
 
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
Re: Findcontrol problem Patrice ASP .Net 0 07-16-2007 05:21 PM
problem with FindControl Terry ASP .Net 2 02-15-2007 10:02 AM
WebControls and sub controls... problem with FindControl... Why? ThunderMusic ASP .Net 2 10-09-2006 04:26 AM
ItemCreated FindControl problem c# =?Utf-8?B?dHBhcmtzNjk=?= ASP .Net 2 06-16-2005 05:11 PM
FindControl problem Jaime ASP .Net 0 05-20-2005 06:49 PM



Advertisments