title: How can I execute Javascript function before Page load?
body: <p>I am using a hidden field 'Isjsenabled' to detect whether Client's Javascript is enabled or disabled. If Javascript is enabled, Javascript function will be fired and it will set hidden field's value to 1. </p>
  
  <p>I want to check the hidden value from server side Page_load. But the problem is Javascript gets fired after Page load.</p>
  
  <p>Do you have any suggestion ? </p>
  
  <p>Html Part</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function() {
          $("#&lt;%= Isjsenabled.ClientID %&gt;").val(1);
      }); 
  &lt;/script&gt;
  
  &lt;input id="Isjsenabled" runat="server" value ="0"  type="hidden"  /&gt;
  </code></pre>
  
  <p>Code Behind Part</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) {                
      HtmlInputHidden hdn = this.FindControl("Isjsenabled") as HtmlInputHidden;
          if (hdn != null)
              if (hdn.Value != null &amp;&amp; hdn.Value == "0")
                  Helper.SetCookie("IJE", "0");
              else
                  Helper.SetCookie("IJE", "1");
  }
  </code></pre>