views:

10

answers:

1

Hi, I've got some controls in my 'GeneralControls' assembly (classic DLL), those consists of .ascx file (and codebehind for them).

I'm referencing that DLL, and using the controls as:

<%@ Register Tagprefix="g" Assembly="GeneralControls" Namespace="GeneralControls.UI" %>


<g:FooterControl ID="Footer" runat="server" />

but, FooterControl contains some other controls (labels, and so on), and those, used from codebehind, throws NullArgumentException. What's the correct way to share ascx controls? Thanks in advance.

+1  A: 

User Controls (.ascx) must exist in the web project they are served from. You cannot move them to another assembly for sharing purposes.

If you want to have shared controls, you need a Custom Server Control which does not have the declarative pattern, all child controls must be created in code by overriding CreateChildControls, etc.

http://support.microsoft.com/kb/893667 (see the section titled "What are the basic differences between user controls and custom controls?")

David
Oh, I hoped that this isn't true, and there is a workaround, or any method how to compile ascx.. Thanks.
Yossarian