btnExportという入力ボタンがクリックされるたびに、Webページで10秒ごとに発生するタイマー間隔を登録する次のjqueryがあります。
if ($) {
$(document).ready(function () {
$("input[id$='btnExport']").click(function ($e) {
// javascript timer function
window.setInterval(ExportProgressCheck, 10000);
});
function ExportProgressCheck() {
$.ajax({
type: "POST",
url: "DMZ_Export.aspx/GetExportProgress",
contentType: "application/json; charset=utf-8",
data: "",
dataType: "json",
success: AjaxSuccess,
error: AjaxFailed
});
}
});
}
ただし、特定のシナリオでは、ページの読み込み自体が読み込まれるとすぐにタイマー間隔が刻々と過ぎ始める必要があります。私の問題は、コードビハインドのページ読み込みイベント内からこれを行う方法がわからないことです。理論的には次のようになります...
protected void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack) {
if (IsExportInProgress()) {
// Register the timer interval now!! How do I do this??
// window.setInterval(ExportProgressCheck, 10000);
}
}
}
}
スタートアップスクリプトを登録してこれを達成しようとしましたが、ExportProgressCheckが何であるかがわからないため、スクリプトが気に入らない...
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(cstype, csname1,
"<script type=\"text/javascript\">window.setInterval(ExportProgressCheck, 10000);</script>",
false);
これに関する助けをいただければ幸いです。ありがとう!