[英]Javascript not Alerting String Variable Value From Code behing C#?
i am trying to alert string variable value using java script from code bhind my code is, 我试图使用代码背后的Java脚本来提醒字符串变量值,我的代码是,
ClientScript.RegisterStartupScript(typeof(Page), "ScriptDescription", "<script type=\"text/javascript\"> alert('Error: Consultant '" + ConsZeroProj + "' projects do not exsist. Please select consultant having projects.');</script>");
ConsZeroProj is string variable having value if i remove this variable it display alert and when i append it . ConsZeroProj是具有值的字符串变量,如果我删除此变量,它将显示警报,并在我追加它时显示。 It do not show any alert what is the reason ?
它没有显示任何警报是什么原因?
hopes for your suggestion thanks 希望您的建议谢谢
Remove single quotes wrapping the variable ConsZeroProj
. 删除包裹变量
ConsZeroProj
单引号。 Use the following code. 使用以下代码。
ClientScript.RegisterStartupScript(typeof(Page), "ScriptDescription", "<script type=\"text/javascript\"> alert('Error: Consultant " + ConsZeroProj + " projects do not exsist. Please select consultant having projects.');</script>");
It is working, tested at my end. 它正在运行,经过我的测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.