LoadControl(字符串)在不同的装配? [英] LoadControl(string) in different assembly?
问题描述
我正在开发一个独立的ASP .NET组件的下降中,我们创造各种网站。
应用程序的一部分是CompositeControl的,这需要加载一个用户控件。
I'm developing a stand-alone ASP .NET component for dropping in to various sites we create. Part of the application is a CompositeControl, which needs to load a UserControl.
不过,CompositeControl的没有LoadControl()方法 - 在代替,我必须(?据我可以看到)依靠Page.LoadControl(),这是一个问题。
However, CompositeControl has no LoadControl() method - in stead, I must (as far as I can see?) rely on Page.LoadControl() and this is a problem!
我如何知道的路径,我的控制,当页面不是组件的一部分?
该页面的CompositeControl位于所在我写在Page.LoadControl()code,因而无法找到我的.ascx文件汇编之外。
How do I know the path to my control, when the page is not part of the assembly? The page the CompositeControl is situated on resides outside the assembly I am writing the Page.LoadControl() code in, and thus cannot find my .ascx file.
我试过LoadControl(类型,对象[]),但这并不加载code盈的文件,这是我所需要的。
I've tried LoadControl(type, object[]) but this doesn't load the "code infront" file, which I need.
所以 - 我怎么找到路径一些.ascx文件里面的一些包括我Page.LoadControl组件(名称已知的,OFC)?或者,有没有一些其他的方式来加载从CompositeControl的?
So - how do I find the Path to some .ascx file inside some included assembly (name known, ofc) for my Page.LoadControl? Or, alternatively, is there some other way to load the control from inside the CompositeControl?
干杯!
编辑:
下面提供的解决方案,虽然是略哈克。然而,它确实工作,:
的http://www.cmswire.com/cms/tips-tricks/aspnet-reusing-web-user-controls-and-forms-000915.php
The following provided the solution, although it is slightly hacky. It does work, however: http://www.cmswire.com/cms/tips-tricks/aspnet-reusing-web-user-controls-and-forms-000915.php
推荐答案
这可能是对你有所帮助:的 http://blogs.msdn.com/b/davidebb/archive/2005/10/30/487160.aspx
This may be of some help to you : http://blogs.msdn.com/b/davidebb/archive/2005/10/30/487160.aspx
这篇关于LoadControl(字符串)在不同的装配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!