title: ClientScript.RegisterForEventValidation and __doPostBack()
body: <p>I'm trying to register some buttons for event registration because I keep getting the "Invalid postback or callback argument". Since I'm passing the buttons' events manually through __doPostBacks(), due to client-side validation, I think it has something to do with that.</p>
  
  <p>I overrode Render to use RegisterForEventValidation like this:</p>
  
  <pre><code>protected override void  Render(HtmlTextWriter writer)
  {
      ClientScript.RegisterForEventValidation(btnNuevo.UniqueID);
      ClientScript.RegisterForEventValidation(btnBorrar.UniqueID);
      ClientScript.RegisterForEventValidation(btnEditar.UniqueID);
      ClientScript.RegisterForEventValidation(btnAlquilar.UniqueID); 
      base.Render(writer);
  }
  </code></pre>
  
  <p>But the __doPostBacks on the client-side .aspx page are written like this:</p>
  
  <pre><code>...
  __doPostBack('&lt;%= btnNuevo.UniqueID %&gt;', "");
  ...
  __doPostBack('&lt;%= btnBorrar.UniqueID %&gt;', selected.childNodes[0].innerText);
  ...
  __doPostBack('&lt;%= btnEditar.UniqueID %&gt;', index);
  ...
  __doPostBack('&lt;%= btnAlquilar.UniqueID %&gt;', indexaux);
  </code></pre>
  
  <p>where selected.childNodes[0].innerText, index and indexaux are strings. This still throws that Exception.</p>
  
  <p>I know there's an overload of RegisterForEventValidation where you pass it a key for the control, and the arguments.</p>
  
  <p>The thing is, I don't know how to write that. I'm not suppossed to know fore-hand what the argument is going to be, since selecter, index and indexaux depend on the user interaction with the page (namely, selecting a row in a GridView). The only examples I find are those where the argument is always the same, so they just write  RegisterForEventValidation("nameOfControl", "XXXX"), where "XXXX" is a fixed string.</p>
  
  <p>Any ideas regarding how to write this, or if this isn't the problem?</p>
  
  <p>Thanks.</p>