如何在Response.Redirect之前运行ScriptManager.RegisterStartupScript

时间:2018-02-20 16:09:08

标签: javascript c# redirect scriptmanager

如何在ScriptManager.RegisterStartupScript

之前运行Response.Redirect

.ASPX代码中的脚本:

<script type="text/javascript">
        var soundObject3 = null;
        function PlaySoundComplete() {
            if (soundObject3 != null) {
                document.body.removeChild(soundObject3);
                soundObject3.removed = true;
                soundObject3 = null;
            }
            soundObject3 = document.createElement("embed");
            soundObject3.setAttribute("src", "Complete.wav");
            soundObject3.setAttribute("hidden", true);
            soundObject3.setAttribute("autostart", true);
            document.body.appendChild(soundObject3);
        }
</script>

Behide代码:

protected void AlertPlaySoundComplete()
{
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "PlaySoundComplete()", true);
}

通话方法功能:

protected void BindDetail
{
   AlertPlaySoundComplete();
   string strRedirect = "confirm.aspx?Item=" + strMat + "," + Customer+ "," + intReasonID.ToString() + "," + Delivery;
   Response.Redirect(strRedirect);
}

此代码不是运行函数AlertPlaySoundComplete();,而是在BindDetail中重定向。我将在重定向页面

之前运行AlertPlaySoundComplete();

0 个答案:

没有答案
相关问题