Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're confusing two completely different "load" events here.</p> <p>First, the server side code (in your case ASP.NET) runs <em>in its entirety</em>. In this cycle, there are a couple of things that happen, and among them are the <code>Load</code> and <code>LoadComplete</code> events.</p> <p>When the server is done determining <em>what should be rendered</em>, it starts sending stuff (HTML and JavaScript, usually) to the browser. On the browser end, <strong>another</strong> <code>load</code> event is triggered - that of the <code>&lt;body&gt;</code> element on the page. They're named the same, but they're completely independent.</p> <p>To fix this problem, set <code>lblText.Text</code> to <code>"value not set"</code> on the server side, and change it in JavaScript when you change the offset indicator.</p> <p>Server side:</p> <pre><code>protected void Page_LoadComplete(object sender, EventArgs e) { // Possibly even better to do this in the properties of the control... lblText.Text = "value not set..."; } </code></pre> <p>Client side:</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; function setOffset() { var curUTCDate = new Date(); var iMins = curUTCDate.getTimezoneOffset(); document.forms[0]['hdnOffset'].value = iMins; document.getElementById('lblText').innerHtml = 'value set'; } &lt;/script&gt; &lt;body id="bodymain" onload="javascript:setOffset();"&gt; </code></pre> <p>If you're not using ASP.NET 4, where you are given extensive control over the client-side IDs of your controls, you should take a look at jQuery. It's a javascript library that you can use for an endless amount of things, which will in this specific case make it a lot easier to find the label control.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload