title: set client id static in asp.net 3.5 for a dynamic generated text box
body: <p>Apply limit of characters on a text box the problem i am facing is that text box is generated dynamically in a data-list  and the client side id does not remain static to apply a java script i need client id static i am using asp.net 3.5 not 4.0 any solution for this.</p>
  
  <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt;
  
  
          function textCounter(field, countfield, maxlimit) {
              if (field.value.length &gt; maxlimit) // if too long...trim it!
                  field.value = field.value.substring(0, maxlimit);
  
              else
                  countfield.value = maxlimit - field.value.length;
          }
  
      &lt;/script&gt;
  
  
  function textCounter(field, countfield, maxlimit) { 
      if (field.value.length &gt; maxlimit) // if too long...trim it! 
          field.value = field.value.substring(0, maxlimit); 
      else
          countfield.value = maxlimit - field.value.length;
  }
  
  
  
    &lt;textarea name="message" id="txtAnswerMain" runat="server" value='&lt;%#Eval("abc") %&gt;' wrap="physical" cols="28" rows="4" 
  onkeydown="textCounter(this.form.message,this.form.remLen,125);" 
  
  onkeyup="textCounter(this.form.message,this.form.remLen,125);"&gt;
   &lt;/textarea&gt;
  </code></pre>