This might seem like a very typically request but I'm not trying to find a control located on the master page from a content page which is making this very hard to figure out.
When I create a user control I also create an external style sheet. This keeps everything nice and neat. I started off putting the htmllink reference in the master page as a static entry but as I create more and more controls, this list is getting longer and being more of a mess. I came up with this brilliant idea of having the master page create a list of user controls and checking to see if a style sheet exists for any of them. If a stylesheet is found then I want it to dynamically add the stylesheet.
I've got the coding for dynamically adding the style sheet. I have the coding for checking to see if the file exists. I keep trying to use page.controls or master.controls to get the list of controls and but I'm not having much luck. I just need to build a list of the control id's that exists on the page. Perferrably on the master page and if possibly on the content page.
This can be done with seperate functions if the master page and the content page needs to be seperate.
I've included some sample code that does not work but that I think is fairly close.
Private Sub UserControlStyles()
Dim Ctrl As Control
Dim UserControlHtmlLink As New HtmlLink
For Each Ctrl In Master.Controls
If TypeOf Ctrl Is UserControl Then
If clsFileSystem.fnFileExists(Server.MapPath("/Styles/Controls/" & Ctrl.ID.ToString & ".css")) Then
UserControlHtmlLink.Href = "/Styles/Controls/" & Ctrl.ID & ".css"