Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Created September 24, 2012 20:02
Show Gist options
  • Save jpoehls/3778025 to your computer and use it in GitHub Desktop.
Save jpoehls/3778025 to your computer and use it in GitHub Desktop.
Do async work in OnClientClick before OnClick PostBack event
<asp:LinkButton ID="btnSave" OnClientClick="return prepareForSave(this);" OnClick="btnSave_Click" runat="server" Text="Save" />
function prepareForSave(sender) {
if (!sender) return;
var hrefToEvalWhenFinished = sender.attributes['href'].value; // Ext.get(sender).getAttribute('href');
if (hrefToEvalWhenFinished) {
// todo: do async work here
// Fire the links HREF event which will do the postback.
eval(hrefToEvalWhenFinished);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment