Ajax second postback not working in Sharepoint in UpdatePanel

本文介绍了解决 SharePoint 页面中 UpdatePanel 在首次提交后无法进行第二次提交的问题的方法,通过修改 JavaScript 代码和注册客户端启动脚本来实现正常的工作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

We have one problem in work, we spend with that two days without any solution, all we found cause some another problem. This is what help us when the page is not making second postback in update panel when the first postback is fired by element in UpdatePanel and refresh only update panels on the page.

Taken from Mike Ammerlaan’s Blog

Windows SharePoint Services JavaScript has a “form onSubmit wrapper” which is used to override the default form action.  This work is put in place to ensure that certain types of URLs, which may contain double byte characters, will fully work across most postback and asynchronous callback scenarios.  However, if your scenarios do not involve double byte character URLs, you may successful disable this workaround and gain the ability to use ASP.NET AJAX UpdatePanels.

To do this, you may need to register a client startup script which disables this workaround, in addition to resetting the default form action:

  1. <script type='text/javascript'>  
  2.   _spOriginalFormAction = document.forms[0].action;  
  3.   _spSuppressFormOnSubmitWrapper=true;  
  4. </script>  

This script may be directly embedded in the page, or could be emitted by a control that uses the UpdatePanel. The following is an example of a very simple method which will fix this issue:

  1. private void EnsureUpdatePanelFixups()  
  2. {  
  3.   if (this.Page.Form != null)  
  4.   {<br />  
  5.     string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];  
  6.     if (formOnSubmitAtt == "return _spFormOnSubmitWrapper();")  
  7.     {  
  8.       this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";  
  9.     }  
  10.   }  
  11.   ScriptManager.RegisterStartupScript(thistypeof(AjaxUpdatePanelPart), "UpdatePanelFixup""_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;"true);  
  12. }  

转载于:https://www.cnblogs.com/Areas/archive/2011/11/29/2267235.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值