Asp.net

如何使用客戶端函式“OnClientClicking”傳遞綁定或評估參數

  • March 10, 2022

我遇到了將參數傳遞給客戶端事件的問題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})") %>'

引用自:https://stackoverflow.com/questions/17525539