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

Avatar of undefined
Last Comment
jschlemmer

8/22/2022 - Mon
jschlemmer

ASKER
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
else
            //Execute method from code behind file that inserts data into SQL Server Database
</script>
ASKER CERTIFIED SOLUTION
jschlemmer

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jschlemmer

ASKER
Found the solution on my own.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck