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.Controls)
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
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.FindControl(this.TargetControlID)
is unable to find that control by its ASP.Net ID.
|All times are GMT. The time now is 03:36 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.