开发者

ASP.NET Controls from different assembly

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.


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?")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜