The way I have always accomplished this....
Put a hidden button on the form:
<asp:Button ID="btnHidden" runat="server" style="display:none;" />
And the server-side code you want to execute goes in the code-behind for this button:
Protected Sub btnHidden_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHidden.Click
'Code goes here
End SubNow, you can programmatically invoke the click of this button with javascript, which will fire the code-behind:
document.getElementById('btnHidden').click();
Hope this helps! Don't forget to mark the most helpful post(s) as Answer for the sake of future readers.