如何在Asp.net 2.0上弹出按钮单击从code进行警示后面? [英] How to popup a Alert on Button Click from code behind in Asp.net 2.0?
本文介绍了如何在Asp.net 2.0上弹出按钮单击从code进行警示后面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这code,但不工作。
I tried this code but is not working ..
protected void btnAbc_Click(object sender, EventArgs e)
{
string script = "<script language='javascript'>alert('abc');</script>";"
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script,true);
}
请咨询。
推荐答案
您有双重脚本标记。添加脚本标记自己:
You have double script tags. Add the script tags yourself:
protected void btnAbct_Click(object sender, EventArgs e) {
string script = "<script type=\"text/javascript\">alert('abc');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
}
或者让方法添加:
Or let the method add it:
protected void btnAbct_Click(object sender, EventArgs e) {
string script = "alert('abc');";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
}
不是两个。
另外还要考虑是否的RegisterStartupScript
方法是你想要做什么更好的选择。
Also consider if the RegisterStartupScript
method is a better fit for what you want to do.
这篇关于如何在Asp.net 2.0上弹出按钮单击从code进行警示后面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文