title: Dynamically check asp net checkbox without postback
body: <p>I have an account management page that will let users change information about themselves. I want to have a checkbox checked when they click on a textbox to start editing it, so that they know, and the program knows what will be updated. I think I can do this with a postback, but I would like to avoid the extra postback if possible.</p>
  
  <p>I figure that this could be done with javascript... but I dont know how.</p>
  
  <p>--Edit--</p>
  
  <p>@Muhammad Akhtar</p>
  
  <p>I made a blank page and tried this here is the code:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/BlueBlack.Master" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="LinkFactory.WebForm2" %&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server"&gt;
  &lt;script type="text/javascript"&gt;
  function update()
  {
    if(document.getElementById('&lt;%=check.ClientID %&gt;').value != '')
    {
      document.getElementById('&lt;%=check.ClientID %&gt;').checked = true;
    }
    else
    {
      document.getElementById('&lt;%=check.ClientID %&gt;').checked = false;
    }
  
  }
  &lt;/script&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"&gt;
      &lt;asp:CheckBox ID="check" runat="server" /&gt;
      &lt;asp:TextBox ID="TextBox1" runat="server" onkeypress="update();"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>-- Edit 2 --</p>
  
  <p>About the answer:</p>
  
  <p>I used his script in the header of my page. For some reason I need to type 2 characters for it to work, but I think that's alright</p>