Jaxcent for .NET

Receiving callbacks from the page

User actions and events such as page loading-unloading can be handled by adding an event handler.

However, occasionally there is a need to have the page send some data that's not covered by the existing events. E.g. you may have an <A HREF> tag in a column in a table, where the intended action is not to go to another page, but to have the server take some action.

For such situations, the page can call the JavaScript method JaxcentServerRequest. This method can be called with zero or more parameters. E.g.

    JaxcentServerRequest('DeleteRow', 'id');
To do this from a button or HREF, use the "javascript:" prefix, e.g.
    <A HREF="javascript:JaxcentServerRequest('DeleteRow', 'id');">
    <BUTTON OnClick="javascript:JaxcentServerRequest('DeleteRow', 'id');">

On the server side, the event OnClientRequestReceived will be fired when this request is received. So simply add an event handler to the JaxcentPage, and do any necessary processing of the command and parameters in the event handler.

This works well if you are embedding a link or a button in a table, and where you will be specifying "id" as a string.Format parameter, e.g.

    <A HREF="javascript:JaxcentServerRequest('DeleteRow', '{1}');">
    <BUTTON OnClick="javascript:JaxcentServerRequest('DeleteRow', '{0}');">
but there are many other situations as well where such custom callbacks can be useful. In particular, this callback mechanism can be very useful when integrating with third party JavaScript code.