我有 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 中使用 LinkButton 的 CommandArgument?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30825562/