Gloria
Gloria

Reputation: 1325

Error in jQuery when ListView returns no data

I'm totally and utterly ignorant when it comes to jQuery so I need your help with changing the following script. This script remains in the Head of an aspx page. It works fine as long as ListView2 returns some data. If the listview2 is empty then I get an error "Object reference not set to an instance of an object." How can I change the script so that the function runs only when ListView2 is populated with data. Thanks

$(function () 
  {
    $("input[id*='checkbox1']").click(function () 
      {
        $("#<%=ListView2.FindControl("DeleteBackground").ClientID
                                %>").removeAttr('disabled');
      });
  });

Upvotes: 1

Views: 28

Answers (1)

RGS
RGS

Reputation: 5211

$(function () {
 $("input[id*='checkbox1']").click(function (e) {
   $("#<%=ListView2.ClientID %>").find("#DeleteBackground").removeAttr('disabled');
 });
});

Upvotes: 1

Related Questions