EDIT: Working user control version (with ascx file, which I want to avoid) can be downloaded from :
http://www.codeproject.com/aspnet/DHTMLMenuASPNET.asp
-------------------------------------------------
I've been writing a custom control that is a CSS-DHTML menu implementation (original CSS, javascript part written by Sylvain Machefert). I made it work perfectly as a user control (with ascx page and its code page), then I wanted it to be purely code to make it available just by moving it's dll. Also in this new version I wanted that some parameters available as child-controls to my menu control, therfore look of DHTML menu can be different in every page it's implemented by simply changing few words in codepage.
It didn't work. For my "menu" and it's child-control (paramControl) I created an empty class project, changed the code as needed (more on that in paragraphs below) and builded with no errors. Then I created a test web project, with one aspx page. I added my "menu" project to my test page solution, and added my assembly to "References" of test page project. I also registered my menu custom control at the top of aspx page:
<%@ Register TagPrefix="CSSMenu" Namespace="CSSMenu" Assembly="menu"%>
It gave me "Could not load type CSSMenu.menu from assembly menu" error, showing line of
<CSSMenu:menu id="Menu1" runat="server"> line in red. After few tries to make it work now I get "?" for parser error message. No code changed actually. It's very frustrating.
Here are the things I did to port my user control to child control parsing pure code version:
1) I changed inherits System.Web.UI.UserControl to Control in order to make it easier for child control parsing.
2) Because there is no ascx page which contains a litteral control that I was filling with menu's html code now, I wrote an overriden render method. All menu code to be in HTML kept in a string which becomes parameter of Output.Wrtite method (Output as you might guess is HtmlTextWriter input of render method).
3) Also for -1- to work I added "Page." in front of all Session variables calls.
4) I added property parameterControls ArrayList and wrote the code below to make paramControl class that has key and value properties for menu parameters:
Protected Overrides Sub AddParsedSubObject(ByVal Obj As Object)
If (TypeOf Obj Is paramControl) Then
_parameterControls.Add(Obj)
End If
End Sub
5) In page_load method of menu control I added for loop below to read parameters:
For i As Integer = 0 To _parameterControls.Count - 1
Dim paramDummy As paramControl = CType(_parameterControls(i), paramControl)
Select Case paramDummy.Key
Case "cssFile"
cssFile = paramDummy.Value
End Select
Next
Basicaly I guess this is all the information that matters.
Any help would be appreciated.