How to execute jquery script before page load?
<p>I need to execute javascript before Page load in ASP.NET application.</p>

<p>My function returns user location, and I would like to pass value to server side and load data based on location.</p>

<p>The problem is javascript function executes after page load.</p>

<p>Here is my code:</p>

<pre><code>    $(function () {
        getLocation();
    });
</code></pre>

<p>in getLocation function I set hidden field value</p>

<pre><code>$("#&lt;%= HfLocation.ClientID %&gt;").val(location);
</code></pre>

<p>in code behind I try to get value but it's always empty</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
        {
            var location = HfLocation.Value;
        }
</code></pre>
