Disable button (in data list) after one click by user
I want to disable a button contained in a data list row. Is it possible to disable the button after the user has clicked once by the user? If yes, please ask someone to suggest how I can achieve this.
<asp:DataList ID="DataList1" runat="server" DataKeyField="Qno" OnItemCommand="DataList1_OnItemCommand"
DataSourceID="SqlDataSource1">
<ItemTemplate> <asp:RadioButton ID="RadioButton1" runat="server" Text='<%# Eval("Ans1") %>' GroupName="qu" />
<br />
<asp:RadioButton ID="RadioButton2" runat="server" Text='<%# Eval("Ans2") %>' GroupName="qu" /> <asp:Button ID="Button2" runat="server" Text="Submit" CommandName="Validate" />
<br />
</ItemTemplate>
+3
source to share
3 answers
I have nothing to do with ASP, but if you want javascript (jQuery) then you can just do something like
$(.once-clickable-button).click(function(){
$(this).attr("disabled", "disabled");
// if needed - do what it is supposed to do
});
(of course add to the button "once by pressing the button" or choose the name that suits you)
+2
source to share