c# - ASP button to open new window to SSRS report with parameter -
i'm building page simple asp.net form c# codebehind. need button (or kind of control) open link new window, , have found code using javascript, , have found code can use make button open ssrs report parameter passed aspx page dynamically. have not found handle both.
my asp form starts simple text box looking npi (type of id). npi used searching database , populating form. want have button on page grab npi entered user , pass new window opening ssrs report.
i've researched , know can use javascript open new window, great, don't know how include user input npi js version. know can't use codebehind open new window, can use response.redirect send npi url ssrs report. can't find combination of two.
thank in advance. first time posting on stackoverflow, though use daily answers. apologize screw-ups i'm making.
the textbox:
<asp:textbox id="npi" runat="server" width="144px"></asp:textbox>
the button opens ssrs report currently:
<asp:button id="reports" runat="server" text="view reports" onclick="reports_click" />
here codebehind button:
protected void reports_click(object sender, eventargs e) { response.redirect("http://myreportserver/pages/reportviewer.aspx?%2fdrpreports%2fapplicantoverview&rs:command=render&npi=" + httputility.urlencode(npi.text)); }
let's try open report in new window. aspx:
<asp:textbox id="txt" runat="server"></asp:textbox> <asp:button id="take" runat="server" onclick="take_click" text="no"/>
the aspx.cs code behind:
response.write("<script>window.open('../about.aspx?qs=" + txt.text + "','_blank');</script>");