Over the last several years web developers have moved more and more code to the browser in an effort to improve the overall user experience.  This code is usually in the form of JavaScript libraries which provide advanced functionality and improved performance.  With the widespread adoption of AJAX developers are pushing our JavaScript skills to the limits.  Even with this increased reliance on JavaScript running in the browser, there is still a need for server side application code.  While the split in application logic has brought some improvements in our user experience, it has brought its own set of challenges as well.  Having application code in two locations often requires us to pass values from the server side to our client-side JavaScript and for the JavaScript to be able to pass those values back to the server.

Jon Galloway rss feed discussed this issue and provided a generic ASP.Net solution in Getting JavaScript and ASP.Net talking (outside of AJAX)Rick Strahl rss feed followed this up with his own solutions in Embedding ASP.Net Server Variables in Client JavaScript Part 1 and Part 2.  Both of these solutions work just fine for generic ASP.Net development.  The downside to both of these techniques is that they require you to load one more component into your application or to dig into how to implement the necessary IScriptControl interface, which Jon points out “it's a little tough to set up”.  More...