[英]alert box disappear without clicking on ok button in asp.net
我要在其中顯示警報框,然后將其重定向到asp.net中的其他頁面
我的代碼是
var s = Convert.ToInt32(Session["id"].ToString());
var q = (from p in db.students
where p.userid == s
select p.sid).SingleOrDefault();
if (q == 0)
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "reg();", true);
}
這是我的reg()函數
function reg() {
var con = alert('Please Register Your Self Fisrt ..!! Thank you');
window.location = "reg.aspx";
}
我的代碼運行正常,但是警報框在幾秒鍾后消失,而沒有單擊它,因為該用戶無法閱讀警報消息
我想將其重定向到reg.aspx,但是在警告框上單擊“確定” ..請幫助
觸發確認框而不是警報將完成您要實現的目標。 您可以選擇有條件或無條件重定向
function reg(){
var con=confirm("You need to register first before proceeding. Redirect to Registration Page");
if(con==true){
window.location = "reg.aspx";
}
else{
//if redirect unconditionally
window.location = "reg.aspx";
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.