i am trying to alert string variable value using java script from code bhind my code is,
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 . It do not show any alert what is the reason ?
hopes for your suggestion thanks
Remove single quotes wrapping the variable 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.