asp.net Web Forms and jQuery Mobile really don't work together. The postback model breaks the way jQuery Mobile ajax works and it will crash when you have more than one page or form. In particular, Web Forms requires a single <form> tag that wraps all the server-side controls, and you cannot enter additional “internal” forms. jQuery Mobile really works best with the ajax model and one or more "pages" ( <div data-role="page"> ) and the forms that are contained in the DOM. Update panels end up causing chaos.
One approach is to simply disable jQuery Mobile ajax downloads. You can do this with this:
//note that the order of script loading here is critical. <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script> $(document).bind("mobileinit", function() { $.mobile.ajaxEnabled = false; }); </script> <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"> </script>
but in the end, you will not have a high-performance website. If the site works through a local wireless network, it can be quite good.
I mainly work in a Web Forms environment and need a jQuery mobile form application for web forms and encoded 5 or so “pages” as one static html file. Then I relied on downloading JavaScript and jQuery ajax to the endpoints of the ASMX web service. I also used KnockoutJS extensively, but of course I could only use JavaScript and jQuery ajax to output the data (and in my case the application was reporting like without updating the data.) If you save the data, you can use the same method.
Better yet, go with asp.net MVC, which eliminates the forced postback model and allows fine-grained control over <form> tags.
I work on a large mobile site and use MVC for the back end and make full use of Razor views, but in the end, I rely on client-side ajax requests for all data and KnockoutJS for almost all dynamic markup. In the end, my client application is different from Web Forms and MVC. MVC-based controllers are easier to work with ajax endpoints and the solution is cleaner.
In general, I would like to combine both solutions into a "one-page application" as well as a SPA approach. There are other approaches that might work with Web Forms, but in my limited research this was the best option.
andleer
source share