javascript DefaultButton Linkbutton fix for FireFox

//panel example:
<asp:Panel ID="pnlMyPanel" runat="server" DefaultButton="lbMyLinkButton">
	<asp:LinkButton ID="lbMyLinkButton" runat="server" onclick="lbMyLinkButton_Click">MyButtonText</asp:LinkButton>
</asp:Panel>

//javascript fix for firefox:
<script type="text/javascript">
	//option 1 existing customers
	var b = document.getElementById('<%= lbMyLinkButton.ClientID %>');
	if (b && typeof (b.click) == 'undefined') {
		b.click = function () {
			var result = true;
			if (b.onclick) result = b.onclick();
			if (typeof (result) == 'undefined' || result) {
				eval(b.getAttribute('href'));
			}
		}
	}
</script>
Thanks to http://kpumuk.info/asp-net/using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/

Updated: Wednesday 9th February 2011, 14:40am

There are 0 comments

Leave a comment of your own

Comments are currently closed.