Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fire server-side methods with jQuery
    text
    copied!<p>I have a large application and I'm going to enabling short-cut key for it. I'd find 2 JQuery plug-ins (<a href="http://jonathan.tang.name/files/js_keycode/test_keycode.html" rel="nofollow noreferrer">demo plug-in 1</a> - <a href="http://code.google.com/p/js-hotkeys/" rel="nofollow noreferrer">Demo plug-in 2</a>) that do this for me. you can find both of them <a href="https://stackoverflow.com/questions/593602/keyboard-shortcuts-with-jquery">in this post in StackOverFlow</a></p> <p>My application is a completed one and I'm goining to add some functionality to it so I don't want towrite code again.</p> <p><strong>So as a short-cut is just catching a key combination, I'm wonder how can I call the server methods which a short-cut key should fire?</strong></p> <p>So How to use either of these plug-ins, by just calling the methods I'd written before? Actually How to fire Server methods with Jquery?</p> <p>You can also find a good article <a href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/#comment-39102" rel="nofollow noreferrer">here, by Dave Ward</a></p> <hr> <p><strong>Update:</strong> here is the scenario. When User press CTRL+Del the GridView1_OnDeleteCommand so I have this</p> <pre><code>protected void grdDocumentRows_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { DeleteRow(grdDocumentRows.DataKeys[e.Item.ItemIndex].ToString()); clearControls(); cmdSaveTrans.Text = Hajloo.Portal.Common.Constants.Accounting.Documents.InsertClickText; btnDelete.Visible = false; grdDocumentRows.EditItemIndex = -1; BindGrid(); } catch (Exception ex) { Page.AddMessage(GetLocalResourceObject("AProblemAccuredTryAgain").ToString(), MessageControl.TypeEnum.Error); } } private void BindGrid() { RefreshPage(); grdDocumentRows.DataSource = ((DataSet)Session[Hajloo.Portal.Common.Constants.Accounting.Session.AccDocument]).Tables[AccDocument.TRANSACTIONS_TABLE]; grdDocumentRows.DataBind(); } private void RefreshPage() { Creditors = (decimal)((AccDocument)Session[Hajloo.Portal.Common.Constants.Accounting.Session.AccDocument]).Tables[AccDocument.ACCDOCUMENT_TABLE].Rows[0][AccDocument.ACCDOCUMENT_CREDITORS_SUM_FIELD]; Debtors = (decimal)((AccDocument)Session[Hajloo.Portal.Common.Constants.Accounting.Session.AccDocument]).Tables[AccDocument.ACCDOCUMENT_TABLE].Rows[0][AccDocument.ACCDOCUMENT_DEBTORS_SUM_FIELD]; if ((Creditors - Debtors) != 0) labBalance.InnerText = GetLocalResourceObject("Differentiate").ToString() + "‏" + (Creditors - Debtors).ToString(Hajloo.Portal.Common.Constants.Common.Documents.CF) + "‏"; else labBalance.InnerText = GetLocalResourceObject("Balance").ToString(); lblSumDebit.Text = Debtors.ToString(Hajloo.Portal.Common.Constants.Common.Documents.CF); lblSumCredit.Text = Creditors.ToString(Hajloo.Portal.Common.Constants.Common.Documents.CF); if (grdDocumentRows.EditItemIndex == -1) clearControls(); } </code></pre> <p>Th other scenario are the same. How to enable short-cut for these kind of code (using session , NHibernate, etc)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload