简体   繁体   English

在ASP.NET中使用Eval将多个字符串参数传递给Javascript

[英]Passing multiple string params to Javascript using Eval in asp.net

I need to pass more than one parameter to JavaScript function from within asp.net. 我需要从asp.net内部将多个参数传递给JavaScript函数。 I tried this solution but it doesn't work when the parameter is string if I replace the string param with another one integer it works properly: 我尝试了这种解决方案,但是如果我将字符串参数替换为另一个整数,则当参数为字符串时它不起作用,它将正常工作:

onClick: '<%# String.Format("test({0},{1})", Eval("O1"),Eval("hometeam")) %>' 

只需在字符串参数的{X}周围加上双引号“”,就像这样

    <input id = "btn_o2" type ="button" style = "width :40px ; height : 18px ;font-size :8 ; height : 18px ;font-size :8" value = '<%# Eval("o2") %>' onclick = '<%# String.Format("addTicket({0},""{1}"")", Eval("O1"),Eval("hometeam")) %>' />

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

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