我有一个SharePoint应用程序页面,我在更新面板中有一个表单。我有一个提交表单的提交按钮。这也仅在更新面板内。提交表单时,我正在显示sharepoint的正在处理对话框。我想在我的代码后面完成提交按钮甚至处理程序后关闭它。我尝试了很多方法,但似乎没有任何效果。
这是我的代码
QuerySubmission.aspx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SummarizeQuery.aspx.cs" Inherits="SummarizeQuery"%>
<SharePoint:CssRegistration runat="server" name="default" />
<SharePoint:CssLink runat="server"/>
<html>
<head>
<link rel="stylesheet" href="~/_layouts/15/defaultcss.ashx" />
<script src="Scripts/jquery-1.9.1.min.js"></script>
<link href="Styles/Hon.Intuition.CN.css" rel="stylesheet" />
<title> submit</title>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server" ID="ReqScriptManager" EnablePartialRendering="true" ></asp:ScriptManager>
<div class="SummarizationParent">
<script type="text/javascript">
$(document).ready(function () {
panelsLoaded = 1;
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(removeWaitScreen);
});
function removeWaitScreen() {
alert('Dines closingh');
if (window.parent.waitDialog != null) {
window.parent.waitDialog.close();
}
}
</script>
<div runat="server" id="divErrorMessages" ></div>
<div>
<asp:UpdatePanel ID="upSummary" runat="server" UpdateMode="Always">
<ContentTemplate>
<script type="text/javascript">
/* adding this to maintain the context during the ajax postbacks */
Sys.Application.add_load(OnPageLoad);
function showWaitScreen() {
window.parent.eval("window.waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Please Wait', 'Please wait as this may take a few minutes...', 125, 450);");
}
</script>
<asp:Panel ID="pnlSummary" CssClass="SummaryPanel" runat="server">
<div class="CN-DialogScroll">
<div>
<table style="padding:5px;width:95%;">
<colgroup>
<col width="35%" />
<col width="60%" />
</colgroup>
<tr>
<td colspan="2"><asp:Label runat="server" CssClass="ms-accentText ms-textXLarge" ID="lblREIMSMetadata"></asp:Label></td>
</tr>
<tr >
<td colspan="2" style="padding:3px"></td>
</tr>
<tr>
<td style="vertical-align: top;">
<asp:Label CssClass="ms-standardheader ms-textXSmall" Text="Shift" runat="server"/>
</td>
<td style="padding:3px">
<span dir="auto">
<asp:DropDownList ID="drpShifts" runat="server"/>
</span>
</td>
</tr>
<tr >
<td colspan="2" style="padding:3px"></td>
</tr>
<tr>
<td style="vertical-align: top;">
<asp:Label CssClass="ms-standardheader ms-textXSmall" Text="Porblem Start Date" runat="server"/>
</td>
<td style="padding:3px">
<span dir="auto">
<SharePoint:DateTimeControl IsRequiredField="true" runat="server" ID="dtProblemStartDate" />
</span>
</td>
</tr>
<tr >
<td colspan="2" style="padding:3px"></td>
</tr>
<tr>
<td style="vertical-align: top;">
<asp:Label CssClass="ms-standardheader ms-textXSmall" Text="Problem Keywords" runat="server"/>
</td>
<td style="padding:3px">
<span dir="auto">
<asp:TextBox MaxLength="48" ID="taKeywords" Width="100%" runat="server"/>
</span>
</td>
</tr>
<tr >
<td colspan="2" style="padding:3px"></td>
</tr>
<tr>
<td style="vertical-align: top;">
<asp:Label CssClass="ms-standardheader ms-textXSmall" Text="Resolution Type" runat="server"/>
</td>
<td style="padding:3px">
<span dir="auto">
<asp:DropDownList ID="drpResolutionType" runat="server"/>
</span>
</td>
</tr>
<tr >
<td colspan="2" style="padding:3px"></td>
</tr>
<tr>
<td style="padding:3px" colspan="2">
<span dir="auto">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClientClick="return showWaitScreen();"
OnClick="btnSubmit_Click"/>
<asp:Label ID="lblStatus" runat="server" Text=" "></asp:Label>
</span>
</td>
</t
</table>
</div>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
在我的代码后面,我有以下事件处理程序代码
protected void btnSubmit_Click(object sender, EventArgs e)
{
//some processing code
this.ClientScript.RegisterStartupScript(this.GetType(), "CloseWaitDialog", "removeWaitScreen();", true);
}
在提交按钮功能完成后,有没有办法调用我的javascript函数removeWaitScreen?
答案 0 :(得分:0)
您可以使用以下功能。
function pageLoad(sender, args) {
removeWaitScreen();
}
以上功能会针对每个更新面板postback
触发。因此,当点击按钮时,updatepanel
将执行postback
,然后将调用pageLoad
,并且将删除等待屏幕。
请参阅此网址以获取ajax updatepanel事件列表 - http://msdn.microsoft.com/en-us/library/bb386417.aspx
另请注意 - document-ready-and-pageload-are-not-the-same
当您尝试使用ClientScript.RegisterStartupScript
时,它与要求execute JS as soon as page loads
相同。