如何在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();