I have 2 asp text boxes that I have attached jQuery to trigger linkbutton server side click if enter key is pressed on any of the 2 text boxes. But this does not seem to work, Please help me explain where and what I am doing wrong. I need a solution that works in all major browsers [IE7,8,9], [Firefox 3,4], Safari[4,5].
Here is my code,
<script language="javascript" type="text/javascript">
function GC_PostBack() {
jQuery('#<%=lnkSubmitGiftCardNumber.ClientID%>').trigger("click");
}
and on server side pn Page_Load, I'm attaching this function to onkeypress event of textboxes.
if (!IsPostBack)
{
txtGiftCardNumber.Attributes.Add("onkeypress", "if(window.event.keyCode == 13) { GC_PostBack(); }");
txtGiftCardPin.Attributes.Add("onkeypress", "if(window.event.keyCode == 13) { GC_PostBack(); }");
}
I have tried using .click() rather then .trigger("click"), but to no avail. Please help!
Thanks.