title: How to change the value of an asp label with JavaScript?
body: <p>I'm trying to add an error label to the top of a panel I have. I have a button created in C# on page load that calls a JavaScript function that I want to display an error message on my panel when clicked.</p>
  <p>C#:</p>
  <pre><code>private void CreateButton(int pID, string changeType)
  {
      ASPxButton btn = new ASPxButton();
      btn.Text = &quot;Execute Request&quot;;
      btn.ID = &quot;btn&quot; + changeType;
      btn.AutoPostBack = false;
      btn.ClientSideEvents.Click = GetClientSideEventHandler(string.Format(&quot;OnProcessRequest(s, e, '{0}','{1}')&quot;, pID.ToString(), changeType));
      TableRow oRow = new TableRow();
      TableCell oCell = new TableCell();
      oCell.CssClass = &quot;table-cell&quot;;
      oCell.Controls.Add(btn);
      oRow.Cells.Add(oCell);
      tblButtons.Rows.Add(oRow);
  
  }
  </code></pre>
  <p>JS:</p>
  <pre><code>function OnProcessRequest$(pID, pChangeType) {
      document.getElementById('errLabel').value = &quot;Test&quot;;
  }
  </code></pre>
  <p>ASPX:</p>
  <pre><code>&lt;asp:Label ID=&quot;errLabel&quot; runat=&quot;server&quot;/&gt;
  </code></pre>
  <p>When this code runs, it always throws the following error:</p>
  <p>Error: Unable to set property 'value' of undefined or null reference.</p>
  <p>I have tried also using:</p>
  <p>document.getElementById('&lt;%=errLabel.ClientID%&gt;').value = &quot;Test&quot;;</p>
  <p>but this also throws the error.</p>
  <p>How can I change the value of this label when this button is clicked in JS?</p>