Reputation: 1252
I am working on an ASP.NET webforms page that has the following asp markup (with additional controls stripped out):
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<asp:LinkButton ID="lnkbtnPreviousTop" OnClick="LinkButtonPrevious_Click"
Text="Previous" runat="server">
</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
Right now, if you click this LinkButton multiple times, the LinkButtonPrevious_Click
event handler on the server side will fire as many times as the link was clicked. How can I make it so that the lnkbtnPreviousTop
LinkButton is disabled after the first click, but the event handler still fires once and the UpdatePanel is refreshed?
I have tried adding this.disabled = true;
to the OnClick attribute, but then the event handler code never gets hit.
Upvotes: 1
Views: 2241
Reputation: 39
can you share answer for solution disabled asp:LinkButton after first click?
@Michael Hornfeck
I try with functions javascript but i havn't answers
<script type="text/javascript">
function disabledLinkBringDataFlow() {
document.getElementById('btnBringDataFlow').setAttribute("disabled", "");
//document.getElementById("btnBringDataFlow").disabled = true;
}
</script>
Upvotes: 0
Reputation: 2645
Just call the postback directly in the onclick, something like:
lnkbtnPreviousTop.Attributes.Add("onclick", "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(lnkbtnPreviousTop, "").ToString());
Upvotes: 2