【问题标题】:Page refresh after postback in UpdatePanel on Sharepoint 2013 publishing page在 Sharepoint 2013 发布页面上的 UpdatePanel 中回发后页面刷新
【发布时间】:2013-02-28 11:34:07
【问题描述】:

当我尝试在第一个完成之前在 Firefox 的 sharepoint 2013 上的 UpdatePanel 中执行第二个 xmlhttprequest 时,我会刷新整个页面。 第一个请求状态为 Aborted。 第二个请求响应是: 1|#||4|97|pageRedirect||%2f_login%2fdefault.aspx%3fReturnUrl%3d%252fsites%252ftest%252fPages%252fUpdatePanelTest.aspx|

这个错误可以用附上的代码重现(快速点击两次按钮会产生错误)。

仅当我将带有此控件的 Web 部件放置在 Sharepoint 2013 上的发布页面上时,才会出现此问题。

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestUpdatePanel.ascx.cs"
Inherits="Example.TestUpdatePanel" %><asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    <asp:CheckBoxList runat="server" ID="CheckboxList1" AutoPostBack="true">
        <asp:ListItem Text="CheckBox1" Value="valueFromCheckBox1" />
        <asp:ListItem Text="CheckBox2" Value="valueFromCheckBox2" />
        <asp:ListItem Text="CheckBox3" Value="valueFromCheckBox3" />
        <asp:ListItem Text="CheckBox4" Value="valueFromCheckBox4" />
        <asp:ListItem Text="CheckBox5" Value="valueFromCheckBox5" />
    </asp:CheckBoxList>
</ContentTemplate></asp:UpdatePanel><asp:UpdatePanel ID="UpdatePanel2" runat="server">
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="CheckboxList1" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
    <br />
    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</ContentTemplate></asp:UpdatePanel>





    protected void Page_Load(object sender, EventArgs e)
    {
        CheckboxList1.SelectedIndexChanged += CheckboxList1_SelectedIndexChanged;
    }

    private void CheckboxList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        Label3.Text = CheckboxList1.SelectedValue;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        Label1.Text = "Button1_Click";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        Label2.Text = "Button2_Click";
    }

【问题讨论】:

    标签: asp.net ajax sharepoint updatepanel


    【解决方案1】:

    您是否有意允许用户在已经有请求的情况下提交回发请求?如果这是无意的,您可能需要考虑在服务器端方法运行时禁用用户控件。这可以通过 UpdateProgress 控件来完成。这个想法是,您可以使用此控件在回发发生时弹出一个覆盖整个应用程序的 div。可以这样使用:

    <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server" >
       <ProgressTemplate >
          <div id="wait" style="width:100%; height:100%; 
                   position:absolute; top:0; left:0; z-index:1000;background-color: #666699; 
                   filter: alpha(opacity=80); text-align:center; vertical-align:middle;">
             <div style="border:5px solid black; width:200px; height:50px; 
                   background- color:White; top:50%; position:absolute;">
                    Saving changes.  Please wait...                                       
             </div>                                       
          </div>                                      
       </ProgressTemplate>
    </asp:UpdateProgress>
    

    【讨论】:

      【解决方案2】:

      默认情况下,更新面板在 SP 2013 中不起作用。您必须按照以下文章进行修复:

      http://msdn.microsoft.com/en-us/library/bb861877.aspx

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-12-25
        • 2014-06-19
        • 1970-01-01
        • 1970-01-01
        • 2012-11-23
        • 2017-03-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多