Thursday, March 1, 2012

LinkButton - Not firing click event in second time

Once in my SharePoint web part I had a strange issue with a LinkButton which placed inside a Grid view.

The click event of the link button does not fire for the second time. This issue is fixed by calling the following javascript in linkbutton OnClientClick event as follows:

Javascript:

<script type="text/javascript">

function setFormSubmitToFalse()
{
_spFormOnSubmitCalled = false;
return true;
}

</script>

LinkButton Control:
<asp:LinkButton ID="btnDate" runat="server" HtmlEncode="false" CommandName="Download" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" Text='<%# Eval("Date")%>' OnClientClick="javascript:setFormSubmitToFalse();"></asp:LinkButton>     

1 comment: