title: How can I get an ASP.NET Session variable into a javascript file?
body: <p>I am refactoring a legacy web app. This app has a is using the onload event inside the body tag (On the Master page) to run this javascript script. Note this script tag is after the form element in the doc. I know the syntax looks hideous (or Visual Studio at least tells it is by the squiggles), but I'll be darned, the thing DOES indeed work.</p>
  
  <pre><code>function DisplayPDF()
  {
      var strPDF
      strPDF = "&lt;%=SESSION("PDF")%&gt;";
      if (strPDF.length != 0)
       {
          window.open(strPDF);
          &lt;%Session("PDF") = ""%&gt;
       }
  }
  </code></pre>
  
  <p>My question is I'm trying to develop a more elegant solution. I have ASP.NET ajax and jQuery both available to me. I wrote a tiny asp.net ajax component that I want to use to handle this. </p>
  
  <pre><code>Type.registerNamespace("ck");
  
  ck.pdfOpener = function() {
    ck.pdfOpener.initializeBase(this);
  }
  
  ck.pdfOpener.prototype = {
      initialize: function() {
          ck.pdfOpener.callBaseMethod(this, 'initialize');
      },
  
      dispose: function() {        
          ck.pdfOpener.callBaseMethod(this, 'dispose');
      },
  
      openPDF: function(){
         //HOW CAN I RETRIEVE A SESSION VARIABLE HERE???
      }
  }
  
  ck.ClientControl.registerClass('ck.pdfOpener', Sys.Component);
  if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
  </code></pre>
  
  <p>Can/Should I be doing it this way? Or should I create a WebService that returns said variable. Thanks for any advice.</p>
  
  <p>Cheers,<br>
  ~ck in San Diego</p>