Link to home
Start Free TrialLog in
Avatar of jschlemmer

asked on

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

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.  
Avatar of jschlemmer


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
Avatar of jschlemmer

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found the solution on my own.