title: Button inside gridview to open new window
body: <p>I have a button inside a gridview. I'm trying to use this button for opening a new window, but I'm getting an error message.</p>
  
  <p>Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
  Details: Error parsing near 'window.open('.</p>
  
  <p>ASP code</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="" Visible="true"&gt;
      &lt;ItemTemplate&gt;
              &lt;asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/picture.jpg" 
              Height="20px" Width="20px" 
              CommandName="OpenGroupTrend"/&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>VB Code</p>
  
  <pre><code>Protected Sub GV_SL_RowCommand(ByVal sender As Object, _
  ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
      If (e.CommandName = "OpenGroupTrend") Then
          Dim GroupTrendLink = "http://NewPage.aspx"
          Response.Write("&lt;script&gt;")
          Response.Write("window.open('" &amp; GroupTrendLink &amp; "','_blank')")
          Response.Write("&lt;/script&gt;")
      End If
  End Sub
  </code></pre>
  
  <p>If I use the same code outside a GridView it works okay. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks</p>