Findcontrol problem

Discussion in 'ASP .Net' started by Arjen, Oct 17, 2005.

  1. Arjen

    Arjen Guest

    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.
     
    Arjen, Oct 17, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:dj0sqv$4fl$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.
    >
    >
     
    Kevin Spencer, Oct 17, 2005
    #2
    1. Advertising

  3. Arjen

    Scott Allen Guest

    On Mon, 17 Oct 2005 21:08:24 +0200, "Arjen" <>
    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/
     
    Scott Allen, Oct 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jaime

    FindControl problem

    Jaime, May 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    671
    Jaime
    May 20, 2005
  2. =?Utf-8?B?dHBhcmtzNjk=?=

    ItemCreated FindControl problem c#

    =?Utf-8?B?dHBhcmtzNjk=?=, Jun 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,515
    =?Utf-8?B?QkVMSVVT?=
    Jun 16, 2005
  3. ThunderMusic
    Replies:
    2
    Views:
    414
    ThunderMusic
    Oct 9, 2006
  4. Terry

    problem with FindControl

    Terry, Feb 15, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    584
    Terry
    Feb 15, 2007
  5. Patrice

    Re: Findcontrol problem

    Patrice, Jul 16, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    Patrice
    Jul 16, 2007
Loading...

Share This Page