【问题标题】:Bind Custom ListView with Jquery - ASP NET使用 Jquery 绑定自定义 ListView - ASP NET
【发布时间】:2017-04-04 16:39:52
【问题描述】:

我有这个自定义ListView

<asp:ListView ID="lvCustomers" runat="server" DataKeyNames="customerID">
    <ItemTemplate>

        <div id="galeria" class="gallery w3-card-4 w3-animate-zoom">

            <div class="w3-container w3-center">
                <asp:Label CssClass="desc_cab" ID="lblCustomerName" Text='<%# Eval("customerName") %>' runat="server" />
            </div>

            <div class="w3-container w3-center">
                <asp:ImageButton CssClass="img" ID="imgCustomer" ImageUrl='<%# Eval("customerPicture") %>' runat="server" alt="Norway" OnClick="imgCustomer_Click"  />
            </div>
        </div>
    </ItemTemplate>
</asp:ListView>



<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "Default.aspx/getCustomer",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
                alert(response.d);
            },
            error: function (response) {
                alert(response.d);
            }
        });
    });

    function OnSuccess(response) {

      // How to written code here?

    }

}
</script>

我需要在后面的代码中创建一个 web 方法并使用 jquery 调用,但是我将如何将 listView 与 jquery 绑定?

【问题讨论】:

  • 您使用 Jquery AJAX 而不是常规 UpdatePanel 是否有特殊原因?

标签: jquery asp.net html listview webmethod


【解决方案1】:

据我所知,我认为你做不到。因为这是由于静态和实例的不同。

如果您这样做只是为了回发页面,那么还有其他一些方法可以避免回发,但是如果您只想通过 Ajax 绑定数据,那么您可以从 WebMethod 返回数据并在 ajax 成功时进行数据绑定.请看这篇帖子here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-27
    • 1970-01-01
    • 2020-02-01
    • 2011-06-10
    • 2012-06-29
    • 1970-01-01
    相关资源
    最近更新 更多