[英]Javascript not Alerting String Variable Value From Database in Code behind C#, but alerting integer variable, why?
[英]Javascript not Alerting String Variable Value From Code behing C#?
我試圖使用代碼背后的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是具有值的字符串變量,如果我刪除此變量,它將顯示警報,並在我追加它時顯示。 它沒有顯示任何警報是什么原因?
希望您的建議謝謝
刪除包裹變量ConsZeroProj
單引號。 使用以下代碼。
ClientScript.RegisterStartupScript(typeof(Page), "ScriptDescription", "<script type=\"text/javascript\"> alert('Error: Consultant " + ConsZeroProj + " projects do not exsist. Please select consultant having projects.');</script>");
它正在運行,經過我的測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.