从一个应用程序到另一个应用程序使用ASCX控件 [英] Utilize ASCX Control From One Application To Another

查看:72
本文介绍了从一个应用程序到另一个应用程序使用ASCX控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我目前有一个现有的Web应用程序.现在,我们要创建一些姐妹站点,这将使我们能够利用主站点中的一些现有类和控件.我建立了一个姐妹站点项目,并添加了对我们主站点DLL的引用,以便可以访问我们的公共"类.这部分工作正常.但是,我们还有一些ASCX控件,我们也想在主要Web应用程序中的姊妹Web应用程序中使用它们.有人知道如何做到这一点吗?

在此先感谢,

Brad

Hello All,

I currently have an existing web application. Now we want to create some sister sites which will allow us to utilize some of our existing classes and controls from our main site. I have one of the sister sites project built and added a reference to the DLL of our main site so to have access to our "common" classes. This part is working just fine. However, we have some ASCX controls that we would also like to use in the sister web application that is from our main web application. Does anyone know how to accomplish this?

Thanks In Advance,

Brad

推荐答案

您不能以这种方式共享用户控件.它们将需要复制到每个项目.如果需要重用控件,则可以将其创建为服务器控件.

您可以使用从公共位置加载用户控件的智能控件,SharePoint在Visual WebParts中使用此方法,但是,您需要将包含用户控件代码的程序集部署到GAC,以便可以使用来自子项目.
You can''t share User Controls in that manner. They would need to be copied to each project. If you need to reuse the controls then create as a server control.

You could use a smart control that loads the user control from a common location, SharePoint uses this method with Visual WebParts, however, you would need to have the assembly containing the user control''s code deployed to the GAC so it would be available from sub projects.


简单. :)只需将您的User Control(ascx)文件添加为现有文件,然后与您的姊妹站点进行编译即可.怎么样?

1.右键单击您的姐妹站点项目.
2.选择添加现有文件.
3.找到User Control(ascx)文件所在的位置,然后选择包含文件后面代码的文件.(即usercontrol.ascx.cs)

希望对您有帮助.
Simple. :) Just add your User Control(ascx) file as existing file and compile with your sister site. How ?

1. Right click in your sister site project.
2. Select Add Existing file.
3. Locate where the User Control(ascx) file exists and select the file including the code behind file.(i.e. usercontrol.ascx.cs)

I hope this helps you well.


这篇关于从一个应用程序到另一个应用程序使用ASCX控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆