title: ASP button to open new window to SSRS report with parameter
body: <p>I'm building a page that is a simple ASP.NET form with C# codebehind. I need a button (or some kind of control) that will open a link to a new window, and I have found code that will do that using Javascript, and I have found code I can use to make my button open my SSRS report with a parameter passed from my aspx page dynamically. I have not found anything to handle both.</p>
  
  <p>My asp form starts with a simple text box looking for an NPI (type of ID). That NPI is used for searching a database and populating a form. I also want to have a button on the page that will grab the NPI entered by the user and pass that to a new window opening my SSRS report.</p>
  
  <p>I've researched this and I know I can use Javascript to open a new window, which would be great, but I don't know how to include the user input NPI into the JS version. I know that I can't use the codebehind to open a new window, but I can use Response.Redirect to send the NPI to the URL for the SSRS report. I can't find the combination of the two.</p>
  
  <p>Thank you in advance. This is my first time posting on StackOverflow, though it use it daily for answers. I apologize for any screw-ups I'm making.</p>
  
  <p>The TextBox:  </p>
  
  <pre><code>&lt;asp:TextBox ID="NPI" runat="server" Width="144px"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>The button that opens my SSRS report currently:  </p>
  
  <pre><code>&lt;asp:Button ID="reports" runat="server" Text="View Reports" 
      onclick="reports_Click" /&gt;
  </code></pre>
  
  <p>Here is the codebehind for the button:  </p>
  
  <pre><code>protected void reports_Click(object sender, EventArgs e)  
  {  
      Response.Redirect("http://myReportServer/Pages/ReportViewer.aspx?%2fDRPreports%2fApplicantOverview&amp;rs:Command=Render&amp;npi=" + HttpUtility.UrlEncode(NPI.Text));  
  }
  </code></pre>