我使用「eval」從數據庫獲取數據並將其放入我的應用程序(添加和刪除聯繫人)。當刪除聯繫人時,確認框顯示工作正常。data(with eval)as jquery-method的參數
但是,我想要的是使用數據(從eval)作爲js函數的參數,以便我可以在確認框中顯示聯繫人名稱。
下面是代碼,這是行不通的。我可以寫什麼來使它工作?
在此先感謝。
<asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
<asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
<asp:Button ID="EditLinkButton" runat="server" CommandName="Edit" Text="Edit" CausesValidation="False" />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" CausesValidation="False" OnClientClick="return confirmOnDelete(<%# Eval("FirstName") %>, <%# Eval("LastName") %>);" />
從JS文件:
confirmOnDelete: function (firstName, lastName) {
if (confirm("Are you sure that you want to delete " + firstName + " " + lastName + " ?") == true) {
alert("tog bort");
}
else {
return false;
}
}
我相信你只需引用你的論點。 'confirmOnDelete('...','...')' – Interrobang 2012-02-26 23:35:02