Problem with FindControl

Discussion in 'ASP .Net Web Controls' started by lisa@starways.net, May 23, 2005.

  1. Guest

    I've been trying to build a tab control, as an alternative to the MS IE
    TabStrip and MultiPage.

    It works great. Except for anything that's actually put onto one of
    the tabs.

    Controls on the tabs render fine, but their postback events and
    postback data changes just don't happen. I've been working a seriously
    kludgy thing to get around this and manually raise postback data and
    event stuff, but I shouldn't have to be doing that. I have the source
    code for the MS IE controls, and they don't do anything like that.

    I did some comparisons in debug mode, and I found a difference, but I
    don't understand the significance of it. If I type in the ID of a
    control that's on one of the tabs, all of its info shows up, in both my
    control and theirs. But if I do FindControl(controlID), the control on
    the MS MultiPage is seen, and the one on mine returns Nothing.

    Here's a partial listing. btnInside is on a Tab in my TabControl, and
    btnDelItem is on a PageView in an MS MultiPage control:

    ?btnInside
    {System.Web.UI.WebControls.Button}
    BindingContainer: {ASP.WebForm4_aspx}
    CausesValidation: True
    ClientID: "btnInside"
    CommandArgument: ""
    CommandName: ""
    Enabled: True
    EnableViewState: True
    ID: "btnInside"
    NamingContainer: {ASP.WebForm4_aspx}
    Page: {ASP.WebForm4_aspx}
    Parent: {MyStuff.WebPL.Tab}
    Site: Nothing
    TemplateSourceDirectory: "/LisaTest"
    Text: "btnInside"
    UniqueID: "btnInside"
    Visible: True

    ?FindControl("btnInside")
    Nothing

    ?btnDelItem
    {System.Web.UI.WebControls.Button}
    BindingContainer: {ASP.default_aspx}
    CausesValidation: True
    ClientID: "btnDelItem"
    CommandArgument: ""
    CommandName: ""
    Enabled: True
    EnableViewState: True
    ID: "btnDelItem"
    NamingContainer: {ASP.default_aspx}
    Page: {ASP.default_aspx}
    Parent: {Microsoft.Web.UI.WebControls.PageView}
    Site: Nothing
    TemplateSourceDirectory: "/QMI"
    Text: "Delete"
    UniqueID: "btnDelItem"
    Visible: True

    ?FindControl("btnDelItem")
    {System.Web.UI.WebControls.Button}
    [System.Web.UI.WebControls.Button]:
    {System.Web.UI.WebControls.Button}
    BindingContainer: {ASP.default_aspx}
    ClientID: "btnDelItem"
    EnableViewState: True
    ID: "btnDelItem"
    NamingContainer: {ASP.default_aspx}
    Page: {ASP.default_aspx}
    Parent: {Microsoft.Web.UI.WebControls.PageView}
    Site: Nothing
    TemplateSourceDirectory: "/QMI"
    UniqueID: "btnDelItem"
    Visible: True

    Neither the PageView or the Tab have an ID set. I'm sure that the
    difference when I try FindControl has to be related to the problem I'm
    having, but I just keep coming up with nothing.

    If anyone can help, I'd be so grateful.

    Thanks,
    Lisa
     
    , May 23, 2005
    #1
    1. Advertising

  2. Hello Lisa

    > Controls on the tabs render fine, but their postback events and
    > postback data changes just don't happen.


    You may try to check in debug mode the "__EVENTTARGET" hidden input value
    (available via request params) against your control's unique id. Obviously
    they don't match and WebForms can't find control to call the
    RaisePostBackEvent method.

    > I did some comparisons in debug mode, and I found a difference, but I
    > don't understand the significance of it. If I type in the ID of a
    > control that's on one of the tabs, all of its info shows up, in both my
    > control and theirs. But if I do FindControl(controlID), the control on
    > the MS MultiPage is seen, and the one on mine returns Nothing.


    Usually problems with FindControl method occur due to NamingContainer or
    unique id issues (for example if a control inherits from the
    INamingContainer interface and one of its child controls also inherits from
    this interface the FindControl method of the parent 'NamingContainer'
    control will not find controls nested within its child 'NamingContainer'
    control). But according to the extract from your debug information it looks
    like both naming containers and unique ids are ok.


    Best regards,
    Sergey

    >
    > Here's a partial listing. btnInside is on a Tab in my TabControl, and
    > btnDelItem is on a PageView in an MS MultiPage control:
    >
    > ?btnInside
    > {System.Web.UI.WebControls.Button}
    > BindingContainer: {ASP.WebForm4_aspx}
    > CausesValidation: True
    > ClientID: "btnInside"
    > CommandArgument: ""
    > CommandName: ""
    > Enabled: True
    > EnableViewState: True
    > ID: "btnInside"
    > NamingContainer: {ASP.WebForm4_aspx}
    > Page: {ASP.WebForm4_aspx}
    > Parent: {MyStuff.WebPL.Tab}
    > Site: Nothing
    > TemplateSourceDirectory: "/LisaTest"
    > Text: "btnInside"
    > UniqueID: "btnInside"
    > Visible: True
    >
    > ?FindControl("btnInside")
    > Nothing
    >
    > ?btnDelItem
    > {System.Web.UI.WebControls.Button}
    > BindingContainer: {ASP.default_aspx}
    > CausesValidation: True
    > ClientID: "btnDelItem"
    > CommandArgument: ""
    > CommandName: ""
    > Enabled: True
    > EnableViewState: True
    > ID: "btnDelItem"
    > NamingContainer: {ASP.default_aspx}
    > Page: {ASP.default_aspx}
    > Parent: {Microsoft.Web.UI.WebControls.PageView}
    > Site: Nothing
    > TemplateSourceDirectory: "/QMI"
    > Text: "Delete"
    > UniqueID: "btnDelItem"
    > Visible: True
    >
    > ?FindControl("btnDelItem")
    > {System.Web.UI.WebControls.Button}
    > [System.Web.UI.WebControls.Button]:
    > {System.Web.UI.WebControls.Button}
    > BindingContainer: {ASP.default_aspx}
    > ClientID: "btnDelItem"
    > EnableViewState: True
    > ID: "btnDelItem"
    > NamingContainer: {ASP.default_aspx}
    > Page: {ASP.default_aspx}
    > Parent: {Microsoft.Web.UI.WebControls.PageView}
    > Site: Nothing
    > TemplateSourceDirectory: "/QMI"
    > UniqueID: "btnDelItem"
    > Visible: True
    >
    > Neither the PageView or the Tab have an ID set. I'm sure that the
    > difference when I try FindControl has to be related to the problem I'm
    > having, but I just keep coming up with nothing.
    >
    > If anyone can help, I'd be so grateful.
    >
    > Thanks,
    > Lisa
    >
     
    Sergey Polyakov, May 31, 2005
    #2
    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:
    672
    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,516
    =?Utf-8?B?QkVMSVVT?=
    Jun 16, 2005
  3. Arjen

    Findcontrol problem

    Arjen, Oct 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,038
    Scott Allen
    Oct 18, 2005
  4. ThunderMusic
    Replies:
    2
    Views:
    415
    ThunderMusic
    Oct 9, 2006
  5. Terry

    problem with FindControl

    Terry, Feb 15, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    585
    Terry
    Feb 15, 2007
Loading...

Share This Page