My Repeater contains multiple LinkButtons that perform a postback when manually clicked. However, my attempts to trigger the click event on a LinkButton using JavaScript have been unsuccessful. I have tried both OnClick and OnCommand without any luck.
LinkButtons:
<asp:Repeater ID="repItems" runat="server" OnItemDataBound="repItems_OnItemDataBound">
<ItemTemplate>
<asp:Panel ID="pnlItem" runat="server">
<asp:LinkButton ID="lnkItem" runat="server" OnClick="lnkItem_OnClick" OnCommand="lnkItem_OnCommand"></asp:LinkButton>
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
Javascript:
eval(LinkButton.attr('href'); //Causes Sys.ParameterCountException
LinkButton.click(); //Nothing happens (no click event on LinkButton)
LinkButton.trigger('click'); //Same as LinkButton.click()
If I set OnClientClick to initiate the postback, the click() functions start working, but it triggers a Sys.ParameterCountException error:
lnkItem.OnClientClick = String.Format("__doPostBack('{0}', '');", lnkItem.UniqueID);
Some suggestions included changing ScriptManager to release mode, but it did not trigger the postback, only removed the error message.
The eval(LinkButton.attr('href');
function works in Google Chrome.