Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / May 2008

Tip: Looking for answers? Try searching our database.

Custom Control question (using Master page)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Wier - 14 May 2008 18:31 GMT
Using my custom control, I need to locate controls in the Content
section - - I know that I can do something like:

If (ctrl Is Nothing And Not page.Master Is Nothing) Then
ctrl = page.Master.FindControl("Content").FindControl(id)
End If

However, this only works if the ContentPlaceholder is actually named
"Content" - - how can I look through any ContentPlaceholder on the page, no
matter what it's ID is?
Stan - 14 May 2008 21:44 GMT
> Using my custom control, I need to locate controls in the Content
> section - - I know that I can do something like:
[quoted text clipped - 6 lines]
> "Content" - - how can I look through any ContentPlaceholder on the page, no
> matter what it's ID is?

This question and the sample code is not making any sense. Any control
on a content page can be referenced directly from within that page no
matter what ContentPlaceHolder it is in.

Please clarify
Stan - 14 May 2008 22:29 GMT
> > Using my custom control, I need to locate controls in the Content
> > section - - I know that I can do something like:
[quoted text clipped - 12 lines]
>
> Please clarify

Sorry, forget that last post. On re-reading I can see you are trying
to write a generic method for a custom control to reference another
control (with a particular id) on the host page which may or may not
be a content page. The FindControl method returns immediate Child
controls but not controls within controls - if you see what I mean -
hence your problem and the need for an explicit reference to a known
instance of a ContentPlaceHolder (named "Content").

I think the answer is to iterate through the controls collection on
the master page and identify the ContentPlaceHolders using the
GetType() method for each for each control.

HTH

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.