• 本文中的信息都是收集来的,来源很多,无法一一列出,望见谅。内容仅作为个人的知识管理。 WindowsSharePointServicesv3基于ASP.NET2.0构建。MicrosoftASP.NETAJAX1.0在MOSS之后推出,因此在某些情况下,ASP.NETAJAX和SharePoint之间存在一些兼容性问题,这些问题将会在
  • 为MicrosoftASP.NETAJAX1.0扩展SharePointweb.config
    我们需要为Ajax注册一些特定的条目。编辑SharePoint的web.config文件,该文件通常位于如下目录:

    c:\inetpub\wwwroot\wss\virtualdirectories\80
     添加<sectionGroup>元素到 <configSections>标记:<configSections>
          <sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35">
         <sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35">
             <sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>
           <sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35">
             <sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="Everywhere"/>
             <sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>
             <sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>
           </sectionGroup>
         </sectionGroup>
       </sectionGroup>
    </configSections>
    添加<controls>节的内容,放在<system.web>/<pages>标记中。    <pages>
         <controls>
           <addtagPrefix="asp"namespace="System.Web.UI"assembly="System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         </controls>
       </pages>   
    在<compilation>标记内的<assemblies>标记中添加下面的内容:      <assemblies>
          <addassembly="System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         </assemblies>
    在<httpHandlers>节中添加下面的内容: <httpHandlers>
         <addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         <addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         <addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"validate="false"/>
     </httpHandlers>
    在HttpModules节中添加下面的注册内容,放在所有已有的注册内容下面  <httpModules>
         <addname="ScriptModule"type="System.Web.Handlers.ScriptModule,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
     </httpModules>
    在<SharePoint>/<SafeControls>节中,添加一条SafeControl,用于MicrosoftAjaxExtensions的System.Web.UI命名空间。  <SafeControls>
         <SafeControlAssembly="System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TypeName="*"Safe="True"/>
     </SafeControls>
    最后,添加下面的configuration标记到web.config文件末尾,在结束标记<configuration>前面。
     <system.web.extensions>
       <scripting>
         <webServices>
         <!--Uncommentthislinetoenabletheauthenticationservice.IncluderequireSSL="true"ifappropriate.-->
         <!--
           <authenticationServiceenabled="true"requireSSL="true|false"/>
         -->
         <!--Uncommenttheselinestoenabletheprofileservice.ToallowprofilepropertiestoberetrievedandmodifiedinASP.NETAJAXapplications,youneedtoaddeachpropertynametothereadAccessPropertiesandwriteAccessPropertiesattributes.-->
         <!--
         <profileServiceenabled="true"
                         readAccessProperties="propertyname1,propertyname2"
                         writeAccessProperties="propertyname1,propertyname2"/>
         -->
         </webServices>
         <!--
         <scriptResourceHandlerenableCompression="true"enableCaching="true"/>
         -->
       </scripting>
     </system.web.extensions>
     <system.webServer>
       <validationvalidateIntegratedModeConfiguration="false"/>
       <modules>
         <addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
       </modules>
       <handlers>
         <removename="WebServiceHandlerFactory-Integrated"/>
         <addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"
              type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         <addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
         <addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler,System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
       </handlers>
     </system.webServer>
    利用AjaxBaseWebPart进行开发

    编写使用该扩展的WebPart最简单的办法就是直接继承别人写好的AjaxBaseWebPart。下面是我用的一个。您也可以用其他的,或自己写一个。
    下面是命名空间引用部分:
     usingSystem;
    usingSystem.Collections.Generic;
    usingSystem.Text;
    usingSystem.Web;
    usingSystem.Web.UI.WebControls.WebParts;
    usingSystem.Xml.Serialization;
    usingSystem.Web.UI;
    usingMicrosoft.SharePoint.WebPartPages;
    usingMicrosoft.SharePoint.Utilities;
    usingSystem.Web.UI.WebControls;
    usingSystem.Drawing;
    下面是AjaxBaseWebPart类的实现部分:
         ///<summary>
       ///AbaseclassthatimplementsallthefunctionalityrequiredtouseASP.netAjaxextensionsinsideWSS
       ///</summary>
       [XmlRoot(Namespace="Deps.AjaxBaseWebpart")]
       publicabstractclassAjaxBaseWebpart:Microsoft.SharePoint.WebPartPages.WebPart
       {
           /*
            *TheideaandthecodebehindthisbasewebpartwastakenfromEricsblogpostat:
            *
            *ThisbasicallymanagesthepresenceandconfigurationoftheScriptManager
            *whichisrequiredbyASP.netajaxextensionstohandlepostbacks,ect.Thiswebpartalsoincludes
            *acommonmethodforhandlingerrors.
            */
           #regionDeclarations
           privatestring_ValidationGroupId;
           privateValidationSummary_ErrorContainer;
           privateScriptManager_AjaxManager;
           #endregion

    #regionConstructor
           publicAjaxBaseWebpart()
           {

    }
           #endregion

    #regionMethods
           ///<summary>
           ///Usedtoprovideacommonwaytodisplayerrorstotheuserofthecurrentwebpart.
           ///</summary>
           ///<paramname="message">Descriptionoftheerrorthatoccured.</param>
           publicvoidRegisterError(stringmessage)
           {
               if(this.Controls.Contains(_ErrorContainer))
               {
                   //thiswayofgeneratingauniquecontrolidisusedinsomeoftheOOBwebparts
                   intuniqueCounter;
                   if(HttpContext.Current.Items["GetUniqueControlId"]!=null)
                   {
                       uniqueCounter=(int)HttpContext.Current.Items["GetUniqueControlId"];
                   }
                   else
                   {
                       uniqueCounter=0;
                   }
                   uniqueCounter++;
                   HttpContext.Current.Items["GetUniqueControlId"]=uniqueCounter;

    //createacustomvalidatortoregisterthecurrenterrormessagewiththeValidationSummarycontrol
                   CustomValidatorcv=newCustomValidator();
                   cv.ID=string.Concat("_Error_",uniqueCounter);
                   cv.ValidationGroup=_ValidationGroupId;
                   cv.Display=ValidatorDisplay.None;
                   cv.IsValid=false;
                   cv.ErrorMessage=message;

    this.Controls.Add(cv);
               }
               else
               {
                   //ifRegisterErroriscalledbeforetheCreateChildControlsoverrideinAjaxBasePartthentransfertheusertoanerrorpageusingtheSPUtility
                   SPUtility.TransferToErrorPage("TheCreateChildControlsfunctionoftheAjaxBaseParthasnotbeencalled. Youprobablyneedtoadd\"base.CreateChildControls()\"tothetopofyourCreateChildControlsoverride.");
               }
           }
           ///<summary>
           ///NeedstobecalledtoensurethattheValidationSummarycontrolisregisteredonthepage. Anychildwebpartswillneedtohavebase.CreateChildControls()atthetopoftheirownCreateChildControlsoverride.
           ///</summary>
           protectedoverridevoidCreateChildControls()
           {
               base.CreateChildControls();

    if(!this.Controls.Contains(_ErrorContainer))
               {
                   _ValidationGroupId=Guid.NewGuid().ToString();

    _ErrorContainer=newValidationSummary();
                   _ErrorContainer.ID="_ErrorContainer";
                   _ErrorContainer.ValidationGroup=_ValidationGroupId;
                   _ErrorContainer.BorderStyle=BorderStyle.Solid;
                   _ErrorContainer.BorderWidth=Unit.Pixel(3);
                   _ErrorContainer.BorderColor=Color.Red;

    this.Controls.Add(_ErrorContainer);
               }
           }
           #endregion

    #regionEvents
           ///<summary>
           ///Oninitfiresbeforepageload.ModificationstothepagethatarenecessarytosupportAjaxaredonehere.
           ///</summary>
           protectedoverridevoidOnInit(EventArgse)
           {
               base.OnInit(e);

    //gettheexistingScriptManagerifitexistsonthepage
               _AjaxManager=ScriptManager.GetCurrent(this.Page);

    if(_AjaxManager==null)
               {
                   //createnewScriptManagerandEnablePartialRendering
                   _AjaxManager=newScriptManager();
                   _AjaxManager.EnablePartialRendering=true;

    //Fixproblemwithpostbacksandformactions(DevDiv55525)
                   Page.ClientScript.RegisterStartupScript(typeof(AjaxBaseWebpart),this.ID,"_spOriginalFormAction=document.forms[0].action;",true);

    //tag:"form"att:"onsubmit"val:"return_spFormOnSubmitWrapper()"blocksasyncpostbacksafterthefirstone
                   //notcalling"_spFormOnSubmitWrapper()"breaksallpostbacks

//returningtrueallthetime,somewhatdefeatsthepurposeofthe_spFormOnSubmitWrapper()whichistoblockrepetitivepostbacks,butitallowsMSAJAXExtensionstoworkproperly
               //itsahackthathopefullyhasminimaleffect
               if(this.Page.Form!=null)
               {
                   stringformOnSubmitAtt=this.Page.Form.Attributes["onsubmit"];
                   if(!string.IsNullOrEmpty(formOnSubmitAtt)&&formOnSubmitAtt=="return_spFormOnSubmitWrapper();")
                   {
                       this.Page.Form.Attributes["onsubmit"]="_spFormOnSubmitWrapper();";
                   }

//addtheScriptManagerasthefirstcontrolinthePage.Form
                   //Idon'tthinkthisactuallymatters,butIdidittobeconsistentwithhowyouaresupposedtoplacetheScriptManagerwhenuseddeclaritevly
                   this.Page.Form.Controls.AddAt(0,_AjaxManager);
               }
           }
       }
       #endregion

#regionProperties
       ///<summary>
       ///ExposesthePage'sscriptmanager.ThevalueisnotsetuntilafterOnInit
       ///</summary>
       [WebPartStorage(Storage.None)]
       publicScriptManagerAjaxManager
       {
           get{return_AjaxManager;}
           set{_AjaxManager=value;}
       }
       #endregion
   }
开发时只要继承这个WebPart就可以添加UpdatePanel,并在里面添加其他控件了。

转载于:https://www.cnblogs.com/dnmidi/archive/2007/10/21/932417.html

基于ASP.NETAJAX的WebPart开发与部署-转相关推荐

  1. 基于ASP.NET MVC+SQLite开发的一套(Web)图书管理系统【100010294】

    摘要 随着互联网的快速发展,各种线下手工业务都开始转向了互联网线上操作,在21世纪的信息革命时代,信息管理系统成为日常信息记录的主流工具. 本文介绍了以VS 2019(Microsoft Visual ...

  2. 如何基于Restful ABAP Programming模型开发并部署一个支持增删改查的Fiori应用

    Jerry之前的文章30分钟用Restful ABAP Programming模型开发一个支持增删改查的Fiori应用 发布之后,有朋友问我,"没错, 我是在你的文章里看到了Fiori应用的 ...

  3. 基于ASP.NET MVC框架开发Web论坛应用程序

    我想通过本系列文章从头到尾构建一个完整的ASP.NET MVC论坛应用程序,最终的目的是探讨和推动使用ASP.NET MVC框架构建应用程序的最佳实践. 1. 简介 在本篇中,我想先从全局方面介绍一下 ...

  4. 基于ServiceStage的微服务开发与部署(二)

    目录 2.微服务开发与部署 2.1. 组织管理 2.2. 仓库授权 2.3. 微服务接入CSE 2.4. 基于源码构建软件包 2.5. 创建环境 2.6. 应用部署 2.7. 外网访问 2.微服务开发 ...

  5. 基于ASP.NET AJAX技术开发在线RSS阅读器(下篇)

    五.逻辑层设计 (一)添加RSS频道 在展开真正的逻辑层设计之前,先让我们简单地浏览一下下面的草图4.图4展示了我对于两个重要ASP.NET AJAX客户端控件-ListView和DataSource ...

  6. 基于asp.net的Web开发架构探索(转)

    问题由来 最近在研究适合团队开发的web架构解决方案,该架构即要适合分工协作又要有一定扩展性,适合不同的数据库需要,因此我查阅了一些资料,初步构想出了一套架构,请各位多多指教. 探索 web开发架构最 ...

  7. 基于asp.net2 C#开发MapServer

    MapServer是个开源GIS,这里不用介绍了. 网上有基于asp.net1.1 C#开发示例(Thinking in GIS  http://www.paolocorti.net) 下载的例子有个 ...

  8. RoadFlow ASP.NET Core工作流引擎IIS部署

    RoadFlow最新版本采用ASP.NET CORE2.1开发,部署步骤和.NET CORE部署一样,具体可参数ASP.NET CORE的部署方式. 1. 获取代码     首先从RoadFlow官网 ...

  9. 基于微软ASP.NET AJAX框架开发幻灯片播放网页

    一. 简介      最近,微软ASP.NET Ajax 1.0框架以其完整的基于Ajax的web开发方案呈现在web技术人员的前面,凭借与遗留ASP.NET系统的有机整合以及完全面向对象的客户端Ja ...

  10. 基于ASP.Net Core开发的一套通用后台框架

    基于ASP.Net Core开发一套通用后台框架 写在前面 这是本人在学习的过程中搭建学习的框架,如果对你有所帮助那再好不过.如果您有发现错误,请告知我,我会第一时间修改. 知其然,知其所以然,并非重 ...

最新文章

  1. 30-hadoop-hbase-安装squirrel工具
  2. Javascript Symbol 隐匿的未来之星
  3. TypeError: decoding Unicode is not supported
  4. protobuf入门教程(六):导入定义(import)
  5. Pycharn比较好的配色方案
  6. vue watch第一次监听不到_Vue 的 computed 和 watch 的区别
  7. mysql数据库优化教程_mysql数据库索引优化学习教程
  8. 邮件营销的三个基本要素讲解
  9. NNIE模型转换环境搭建
  10. 泛泰A850 (高通8064+720p)刷4.4专用中文recovery TWRP2.7.1.3版
  11. 花生壳:将内网端口映射到外网
  12. TCGA临床数据整理
  13. Ribbon 服务调用
  14. 金融初学者的感受:兴趣的魔力
  15. session Asii码转换
  16. 计算机辅助翻译在翻译中的应用,计算机辅助翻译系统在翻译教学中的应用
  17. [Xcode]自己常用的Code Snippets、Xcode插件、文件目录
  18. linux-top命令详解
  19. dnf跨6服务器维护,地下城与勇士DNF2018全跨区表一览
  20. 不同坐标系数据切片统一方法

热门文章

  1. Spring学习(二)代理模式(静态代理、动态代理)、Spring AOP
  2. 项目中的每个层的理念是什么?
  3. spark结构化流保存mysql_[Spark]-结构化流之输出篇(待重修)
  4. mysql怎么导入代码_mysql导入数据步骤mysqlimport
  5. 时域上的乘积等于频域上的卷积_图卷积神经网络:Graph Convolutional Networks
  6. springboot不返回指定的字段(隐藏字段)
  7. 【cookie,session】cookie和session基础知识入门
  8. IDEA 2020.3 更新了,机器学习都整上了
  9. MyBatis 持久化框架快速使用入门(Xml配置版)
  10. Tomcat startup.bat 后台运行,不再弹出 Dos 黑框