最近在WebPart中使用UserControl时,找到一种比较简单的方法,步骤如下: 

第一步:创建一个Class Library的工程。
比较简单的在WebPart中使用UserControl的方法

第二步:添加对System.Web的引用
比较简单的在WebPart中使用UserControl的方法

第三步:创建一个Web Application做为UserControl的容器
比较简单的在WebPart中使用UserControl的方法

第四步:创建一个简单的UserControl
比较简单的在WebPart中使用UserControl的方法

第五步:在你创建的class library的工程中添加对UserControl所在工程的引用
比较简单的在WebPart中使用UserControl的方法

第六步:实现一个WebPart,注意在Page.LoadControl()中的路径,稍候解释。
比较简单的在WebPart中使用UserControl的方法

第七步:把class library工程的bin目录中的两个dll文件复制到你的Sharepoint站点的bin目录中,修改.config文件,注意,只需把MinSentinelWebPart的信息添加至.config文件即可。
比较简单的在WebPart中使用UserControl的方法

第八步:把UserControls文件夹复制到Sharepoint站点中,与bin目录平行。刚才的路径就是MinSentinelWebPart.dll相对于MyUserControl.ascx文件的相对路径
比较简单的在WebPart中使用UserControl的方法

至此就大功告成了,接下去你只需像使用其他的WebPart一样使用它就好了。

转载于:https://www.cnblogs.com/MinSentinel/archive/2007/11/02/947537.html

相关文章:

  • 2021-10-13
  • 2022-12-23
  • 2022-02-05
  • 2021-05-18
  • 2021-11-25
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案