如何正确传递给评估和演示javascript函数? [英] How to Properly pass Eval to javascript function?

查看:84
本文介绍了如何正确传递给评估和演示javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是传递一个asp.net值转换为JavaScript的正确方法?举例来说,此行code的说我缺少一个令牌。

 < ASP:ImageButton的=服务器的ImageUrl =/ ESDNET /图片/图标/ add.png的OnClientClick =回报ShowNewNoteForm(<%#的eval( SuggestionID)的ToString()%方式>);/>


解决方案

最后用下面的一把扯下:

 < ASP:ImageButton的=服务器ID =addNote的ImageUrl =/ ESDNET /图片/图标/ add.png的OnClientClick ='<%#字符串。格式(回归ShowNewNoteForm(\\{0} \\)的eval(SuggestionID))%GT;/>

What is the proper way to pass an asp.net value into javascript? For instance, this line of code says I am missing a token..

<asp:ImageButton runat="server" ImageUrl="/ESDNET/Images/Icons/add.png" OnClientClick="return 'ShowNewNoteForm("<%# Eval("SuggestionID").ToString() %>");'/>

解决方案

Finally pulled it off with the following:

 <asp:ImageButton runat="server" ID="addNote" ImageUrl="/ESDNET/Images/Icons/add.png" OnClientClick='<%# String.Format("return ShowNewNoteForm(\"{0}\")", Eval("SuggestionID")) %>'/>

这篇关于如何正确传递给评估和演示javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆