简体   繁体   English

来自asp.net的警报框3.5 Code-Behind

[英]alert box from asp.net 3.5 Code-Behind

protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
{           
    if (ddlLanguage.SelectedValue=="es-ES")
    {
        Page page = HttpContext.Current.CurrentHandler as Page;

        page.ClientScript.RegisterStartupScript(typeof(Page), "Script", "<script language='javascript'>alert('All content may not be in Spanish. Do you want to continue...');</script>");            
    }
}

All I want to do is display a simple alert box but all in vain...nothing pops-up. 我想要做的只是显示一个简单的警报框,但都是徒劳的...没有任何弹出窗口。 need some ayudar. 需要一些ayudar。

You need to verify if the startup script is not registered already. 您需要验证启动脚本是否尚未注册。 Check out this post. 看看这篇文章。

Also you can build your custom MessageBox in ASP.NET. 您还可以在ASP.NET中构建自定义MessageBox。 Check out this one . 看看这一个

You can also achieve in this way 你也可以用这种方式实现

protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
{           
  if (ddlLanguage.SelectedValue=="es-ES")
   {         
      Response.Write("<script>alert('All content may not be in Spanish. Do you want to continue...');</script>");            
   }
}

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showalert","Alert Message", true); ScriptManager.RegisterStartupScript(this.Page,this.GetType(),“showalert”,“Alert Message”,true);

This works for me without Postback try this 这对我来说没有Postback尝试这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM