zoukankan      html  css  js  c++  java
  • Building Web Parts for SPS读书笔记(2)

    Building Web Parts for SPS读书笔记(2)

     

    本篇学习如何使用ASP.NETUser Controls来创建Web Part的外观,简化Web Parts的开发和测试。

     

    SharePoint请求机制

    SharePoint站点承载于IIS 6.0 Server,并有ISAPI filterstsfltr.dll)截取所有的请求消息。由SharePoint framework处理这些情况,SharePoint框架参考配置数据库(config database)并基于内容数据库(content database)的信息产生响应。因为这些都运行在ASP.NET框架平台,因为一个HttpHandler (Microsoft.SharePoint.ApplicationRuntime.SharePointHandlerFactory)负责生成SharePoint页面的动态响应。

    这样,普通的ASP.NET applicationsWeb ServicesSharePoint扩展的服务器上运行将有困难,可以避免stsfltr.dll截取对普通的ASP.NET applicationsWeb Services请求的唯一方法是增加这些站点到SharePointExcluded Paths,具体操作可以参考《配置SPS的托管路径written by Rickie

     

    创建ASP.NET User Control

    通过VS.NET轻松创建User Control(.ascx),包括完整的事件处理。该User Control将最终放置在Web Part中。

     

    Web Part中创建User Control

    User Control开发测试完成后,下一步将User Control嵌入到Web Part中。基于Web Part library创建一个新的项目,该项目需要引用上述ASP.NET User Control编译生成的assembly文件。

    此时,CreateChildControls()方法仅需要包含如下代码:User Control对象的创建并增加到Web Partcontrols集合。

    proteced MyUserControl myUserControl = null;

    protected override void CreateChildControls()

    {

       this.myUserControl = (MyUserControl)Page.LoadControl(“/wpresources/MyUserControl.ascx”);

       this.Controls.Add(this.myUserControl);

    }

    注:MyUserControl指上述创建的ASP.NET User Control类。

     

    protected override void RenderWebPart(HtmlTextWriter output)

    {

       this.EnsureChildControls();

       this.myUserControl.RenderControl(output);

    }

    ReaderWebPart()方法中,先调用EnsureChildControls()方法,然后让User Control对象Render自身。

     

    部署Web Part

    1. SPS web.config配置文件注册该Web PartSafe Control.

    2. 同时将Web Part dllUser Control dll文件部署在bin目录或GAC.

    3. User Control ascx文件复制到wpresources目录.

     

     Web Part开发人员使用ASP.NET User Controls技术来创建Web Part的内容,通过这种方式,不仅提高开发人员的效率(因为可以利用VS.NET的可视化设计器),而且可以在通常的ASP.NET页面进行测试或debug

     

    References:

    1. Patrick Tisseghem, Building Web Parts for Microsoft SharePoint Products and Technologies, Part II - Web Parts and User Controls, http://www.microsoft.com/belux/nl/msdn/community/columns/tisseghem/webparts2.mspx

    2. Patrick Tisseghem, Building Web Parts for Microsoft SharePoint Products and Technologies

    3. Rickie, Building Web Parts for SPS读书笔记(1)

     

     

  • 相关阅读:
    【jquery ,ajax,php】加载更多实例
    关于scrollTop
    jquery 底部导航透明度变化
    jquery 处理密码输入框(input type="password" ) 模仿placeholder
    物化视图基于rowID快速刷新
    ora-01653 无法通过1024扩展
    oracle临时表空间
    java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Integer
    redis 简单使用
    BigDecimal 运算
  • 原文地址:https://www.cnblogs.com/rickie/p/79852.html
Copyright © 2011-2022 走看看