Working Between Server Side and Client Side Code for Offline Web App

jschlemmer used Ask the Experts™
I have a .Net 4 Web Application (c#) that will mostly be accessed via mobile devices.  We want to allow as much of the site as possible to be available offline using HTML5.  The only issue I am really struggling with is creating communication between the server side code and the javascript (and vice versa) to do this.  For example, if the employee uses the site to update the status of the job they are working on, I want On Submit to have javascript check for connectivity.  If not connected,store values in Web Sql or Cookie until connectivity is obtained.  Or if connected execute server side code from the code behind syncing the new values with the server.  So really two questions:

1)  Is there a way to execute a code behind method from javascript in aspx page? Definitely preferred if possible.
2)  If I utilize ClientScript.RegisterStartupScript to run the javascript side of things so that everything would be done from code behind, would this functionality still truly be available offline.  

I genuinely do not even wish for the server side code to even attempt to execute if there is no connectivity which is why an answer to question 1 would be most preferred.  Rather, I'd like it to simply alert the user that they are not connected, save the data locally and the data will sync later, essentially failing gracefully allowing the user to continue using the site.  
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


Thanks for the prompt reply, however, it does not answer my questions.  Your link to question 1 explains how to call javascript from code behind.  I am trying to accomplish the opposite.  Call code behind from Javascript.  Your other links just explain HTML5 which I've already got working.  I have the Web Sql Tables and Cache Manifest done.  What I really need is something like:

<script type ='text/javascript">
if (internet not connected)
             //Save data to HTML5 Web Table until connection is obtained
            //Execute method from code behind file that inserts data into SQL Server Database
Using Web Services and JQuery, I got this working.  Just create the web service to run all the server side code but control whether it is executed by calling the web service when connected using JQuery and AJAX.


Found the solution on my own.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial