I have asp button, which functionality is for deleting the item. Button is inside the update panel. I have datalist in that I have adding the Item and with every time I have a checkbox. I have 2 button Select All and Clear All, I am selecting all the item with my Select All button that is JQuery Code after that I am trying to delete the time. when I am selecting the item one by one then its working fine, when selecting all items then its not working.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Enabled="false" Text="Delete"
OnClientClick="return confirm('Are you sure?');$.loading({ mask: true, effect: 'ellipsis update' });"
OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
HTML it is generating..
<div id="Tab1_UpdatePanel1">
<input type="submit" id="Tab1_Button1" value="Delete Image" name="Tab1$Button1">
</div>
JQuery for Enabling disabling Button1
$("#[id$='btnCheckAll']").click(function () {
$("#<%= dlst1.ClientID %> input:checkbox").attr("checked", "checked");
$("#<%=Button1.ClientID %>").removeAttr('disabled');
});
$("#[id$='btnUnCheck']").click(function () {
$("#<%= dlst1.ClientID %> input:checkbox").removeAttr("checked");
$("#<%=Button1.ClientID %>").attr('disabled', 'disabled');
});
and on page_load also I am making Button1.Enable=false; and when I am selecting any item I directly without using checkbox i am making Button.Enabled=true over there.
Button functionality is working fine but Confirm box is not showing, I checked this Question also but not working for me.
When I am making my button enable then its working fine, But I have the condition where I need to disable the button and based on some condition i am enabling the button. then its not working.
Please someone help me?
尝试嵌入按钮,然后单击它..它肯定可以工作
It seems you encounter the problem using jquery, try these alternative solutions:
simple javascript:
<asp:Button ID="Button1" runat="server" Text="Delete User" OnClientClick="return confirm('Are you sure you want to delete this user?');" />
Ajax ConfirmButtonExtender:
<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server" TargetControlID="Button1" ConfirmText="Are you sure you want to click this?" OnClientCancel="CancelClick" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.