title: JavaScript strange behaviour when using PostBack
body: <p>I’m having some troubles related to JavaScript in my web application. The code is actually simple, I just want to create a certain number of buttons using the command asp:Repeater and, in case of button click events, open a pdf file in a new tab.  I’m using the follow code to do that:</p>
  
  <pre><code>&lt;asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound"&gt;
    &lt;ItemTemplate&gt;
      &lt;div class="home_content2_item"&gt;
        &lt;asp:LinkButton ID="lkb1" runat="server" CommandArgument='&lt;%#Eval("ID") %&gt;' OnCommand="lkbDestaque_Command" OnClientClick="return PostToNewWindow();"&gt;
          &lt;% if (language() == "pt-BR") %&gt;
          &lt;% { %&gt;
          &lt;%# Eval("Title") %&gt;
          &lt;% } %&gt;
          &lt;% if (language() == "es-CL") %&gt;
          &lt;% { %&gt;
          &lt;%# Eval("Title_es") %&gt;
          &lt;% } %&gt;
          &lt;% if (language == "en-GB") %&gt;
          &lt;% { %&gt;
          &lt;%# Eval("Title_en") %&gt;
          &lt;% } %&gt;
        &lt;/asp:LinkButton&gt;
      &lt;/div&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>with the following javascript:</p>
  
  <pre><code>function PostToNewWindow() {
      originalTarget = document.forms[0].target;
      document.forms[0].target = '_blank';
      window.setTimeout("document.forms[0].target=originalTarget;", 600);
      return true;
  }
  </code></pre>
  
  <p>The strange thing is that the PostBack command don’t work for the first button, but works just fine for the other ones. </p>
  
  <p>I’m getting this error when clicking the first button: “_dopostback error in null or undefined not a function object”.</p>
  
  <p>Have you guys ever had a problem like that? Does someone have any idea about how to solve this?</p>