jquery - 如何在 jQuery 中使用 LinkBut​​ton 的 CommandArgument?

标签 jquery commandargument

我有 5 个链接按钮。我想将它们的命令参数发送到 Web 方法以在页面滚动上加载。

$.ajax({
    type: "POST",
    url: "Default.aspx/GetCustomers",
    data: '{pageIndex:'+pageIndex+'}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess,
    failure: function (response) {
       alert('Hell 1');
    },
    error: function (response) {
        alert('Hell 2');
    }
});

最佳答案

不,你不能在 jQuery 中使用 CommandArgument,因为它存储在页面的 View 状态中。但您可以使用 data-... 属性代替。

<asp:LinkButton ID="btnSave" runat="server" Text="Save" data-id="<%# DataBinder.Eval(Container.DataItem, "ID") %>" />
<script>
    var id = $('#btnSave').data('id');
    // use id
</script>

关于jquery - 如何在 jQuery 中使用 LinkBut​​ton 的 CommandArgument?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30825562/

相关文章:

javascript - 根据 DOM 中的位置对包含 DOM 元素的数组进行排序

javascript - 如何为 jquery-bootgrid 设置工具提示

c++ - 使用系统 ("pause") 当命令参数已设置为数据文件时

javascript - 将 javascript 值传递给链接按钮的 CommandArgument

javascript - JQuery 延迟后淡入

javascript - 纯 CSS 导航栏 :Hover on List not staying

javascript - 我需要在 Jquery 中从 'active' 项目开始循环

javascript - 在同一 aspx 页面上的 commandArgument 中传递选定的下拉文本?

c# - 动态添加的 ASP.Net 按钮无法调用 Click 或 CommandArgument 事件

asp.net - asp 按钮的 e.CommandArgument 不起作用