如何使用客户端函数传递绑定或 eval 参数"OnClientClicking"



我遇到了向客户端事件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]。

也是同样的错误

将的双引号改为单引号

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

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

或者删除你的string.Format并像这样使用

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

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

使用此格式

OnClientClick='<%#"text1"+Eval("值")+";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?");"

最新更新