如何使用客户端函数“OnClientClicking”传递bind或eval参数

问题描述 投票:0回答:4

我遇到了向客户端事件传递参数的问题

OnClientClicking

我尝试使用

String.Format ()
功能,但不起作用。

您有解决方法来发送与

OnClientClicking
链接的参数吗?

代码

asp

<telerik:RadButton ID="bnt_meetingDelete" runat="server" OnClientClicking="<%# string.Format("confirmCallBackFn('{0}');",Eval("MeetingID")) %>" Image-ImageUrl="~/image/icone/delete-icon.png" Image-IsBackgroundImage="true" Width="21" Height="21" telerik:RadButton>

错误

IIS

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: The server tag is not well formed.

我尝试使用控制器[asp: ImageButton]。也是同样的错误

asp.net eval bind onclientclick
4个回答
25
投票

将双引号更改为单引号从

OnClientClicking="<%#string.Format("confirmCallBackFn('{0}');",Eval("MeetingID")) %>"

OnClientClicking='<%#string.Format("confirmCallBackFn('{0}');",Eval("MeetingID")) %>'

或者删除你的

string.Format
并像这样使用

OnClientClicking='<%# "confirmCallBackFn("+ Eval("MeetingID") + ");" %>'

1
投票

尝试

OnClientClicking='<%# Eval("MeetingID", "confirmCallBackFn({0})") %>'


0
投票

使用此格式

OnClientClick='<%# "text1" + Eval("value") + "text2" %>'

让你正确转义

\"
,使其正常工作:

OnClientClick='<%# "return confirm(\"Are you sure you want to unlock this user " + Eval("Lockout") + "?\");" %>'/>

渲染后会是这样的:

onclick="return confirm("Are you sure you want to unlock this user True?");"

0
投票

只是分享,VB.net,框架版本4.6.1。

OnClientClick='<%# String.Format("return confirm(Hello team: ""{0}"");",Eval("Name")) %>'

© www.soinside.com 2019 - 2024. All rights reserved.