Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Webparts and FindControl

Reply
Thread Tools

Webparts and FindControl

 
 
Josh Valino
Guest
Posts: n/a
 
      04-02-2008
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
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.FindControl(this.TargetControlID)
is unable to find that control by its ASP.Net ID.

Any thoughts?

TIA


 
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
Do MasterPages and WebParts not mix! =?Utf-8?B?SmF2?= ASP .Net 2 06-12-2006 03:18 PM
How to give 3d Look to Datagrid and WebParts control? =?Utf-8?B?U2hlbGw=?= ASP .Net 1 10-28-2005 04:38 PM
Webparts and ViewState =?Utf-8?B?QXN0ZXJh?= ASP .Net 0 06-07-2005 05:55 PM
ASP.Net Framework2 and webparts ALI-R ASP .Net 1 03-16-2005 01:11 PM
Sharepoint Webparts Session and Application Variables Tom ASP .Net 0 01-23-2004 09:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57