title: Execute a javascript function only if session["x"]="ok"; if it is not, not execute!
body: <p>Well i have 2 aspx
  page1 you are going to have amm two buttons or it dontmind but the goal is...</p>
  
  <p>when user press button1 in page1.aspx, session["x"] will be equals to "ok"
  if users press button2 in page1.aspx, session["x"] will be eauls to null;</p>
  
  <p>so after press any button user will be redirected to page2.aspx.</p>
  
  <p>i want to execute a javascript function if session is equals to "ok" and not to do it
  if session is null, someidea? when page2.aspx is open javascript function will be done automatically, if it is null, javascript function will not be nothing or it will not be executed. some idea? thanks guys!</p>
  
  <p>it worked so...</p>
  
  <p>the real code was it..</p>
  
  <pre><code>&lt;% if (Session[@"codigodiagrama"] != null){%&gt;
         &lt;script type="text/javascript"&gt;
           window.onload=  function () {
                 alert('with code');
             }
  
         &lt;/script&gt; 
       &lt;% } %&gt;
  
        &lt;% if (Session[@"codigodiagrama"] == null){%&gt;
         &lt;script type="text/javascript"&gt;
             window.onload= function () {
                 alert('null');
             }
  
  
         &lt;/script&gt; 
       &lt;% } %&gt;
  </code></pre>
  
  <p>now i want to pass the session["codigodiagrama"] to the function
  if it has code to pass the String (codigodiagrama)</p>
  
  <p>i refer how to pass this session to this windows.onload =function(pass code here)</p>