Webparts and FindControl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Josh Valino

    #1

    Webparts and FindControl

    Hi. I'm using asp.net 2.0 at my job and we have a site that uses webparts.
    I'm curious if anyone can answer this. In the OnPreRender event of a
    webpart, I have this:

    foreach(Control x in this.Page.Contr ols)
    {

    }

    As I step through this code, only one control is found, that is the master
    page for the page that this web part sits in. The actual aspx page itself
    has other controls, however. If I do this same loop in the actual
    codebehind for the aspx, I get the expected results of seeing the other
    controls that are in the page (labels, buttons, and what not)

    What I'm trying to do is make it such that WebPart1 can get the clientID of
    WebPart2, so that I can add some javascript in WebPart1 that will need to
    reference WebPart2 by clientID. In WebPart1 I have a public property called
    TargetControlID , and I set this property in the ASPX page that contains both
    webparts. In the code for WebPart1, Page.FindContro l(this.TargetCo ntrolID)
    is unable to find that control by its ASP.Net ID.

    Any thoughts?

    TIA


Working...