0

I had a page with many FileUploads and I am having a problem with jQuery to fire up 2 .click events to remove files at the certain point when a RadioBoxList .click(is selected) event, two buttons calling same function as delete_Click on code behind..

My code as following :

<asp:Button ID="delBtn1" runat="server" Text="DeleteFile" OnClick="delete_Click" ClientIDMode="Static" />
<asp:Button ID="delBtn2" runat="server" Text="DeleteFile" OnClick="delete_Click" ClientIDMode="Static" />
$("#rblist").click(function() {
  if ($("#rbl_1").prop("checked")) {
    $(".someclass").hide();
    uploadCheck1();
    uploadCheck2();
    $("delBtn1").click();
    $('delBtn2').click();
  }
});

first click never fired, wondering where is the problem? I am new to jQuery and hoping someone can point out my mistake,thank you!

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
Jackson
  • 5
  • 5

3 Answers3

1

You need ClientID to get ASP.NET controls with jQuery:

$('#<%= rblist.ClientID %>').click(function() {
if ($('#<%= rbl_1.ClientID %>').prop("checked")) {
$(".someclass").hide();
uploadCheck1();
uploadCheck2();
$('#<%= delBtn1.ClientID %>').click();
$('#<%= delBtn2.ClientID %>').click();
}
});
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
  • with ClientIDMode="Static" attribute I can use static ID no? – Jackson Mar 31 '16 at 09:24
  • @Jackson...Have a look at this: http://stackoverflow.com/questions/6057490/is-there-any-drawback-to-set-clientidmode-static-on-every-object-set-on-main – Salah Akbari Mar 31 '16 at 09:26
  • @Shree...Take a look at this post: http://weblog.west-wind.com/posts/2010/May/04/Whats-New-in-ASPNET-40-Part-Two-WebForms-and-Visual-Studio-Enhancements – Salah Akbari Mar 31 '16 at 09:35
0

Use the dblclick event

$(document).ready(function(){
    $("p").dblclick(function(){
        alert("The the page.");
    });
});
Harshil Kulkarni
  • 411
  • 5
  • 20
-1

you are selecting the button control with id so you need to specify the Jquery id selector(#)

try below code

$("#rblist").click(function() {
  if ($("#rbl_1").prop("checked")) {
    $(".someclass").hide();
    uploadCheck1();
    uploadCheck2();
    $("#delBtn1").click(); //change here
    $('#delBtn2').click();//change here
  }
});
Satish Kumar sonker
  • 1,250
  • 8
  • 15