Somebody help me please.. i have make a research on how to retrieve query string using java script but it seems not success. I need to open window print view for a form (different web form) when user click on button that is placed in grid view. Every row in grid view have its own print button as its have different id as the form data are retrieve from id(primary key in database which refer to trip id. Below is my code for java script. The print window able to open but the form data is not retrieve.
<script type="text/javascript">
function printExternal() {
var data='<%=this.Request.QueryString["tripid"]%>';
var printWindow = window.open('PrintBusinessTrip.aspx?tripid=' + data, 'Print', 'left=200, top=200, width=950, height=500, toolbar=0, resizable=0');
printWindow.addEventListener('load', function () {
printWindow.print();
printWindow.close();
}, true);
}
</script>
Here is the button,
<asp:Button ID="sendbtn" runat="server" OnClientClick="printExternal();" PostBackUrl='<%#"~/PrintBusinessTrip.aspx?tripid="+Eval("tripid")%>' Text="Print" />
It only success when I hard code the id like this,
var printWindow = window.open('PrintBusinessTrip.aspx?tripid=102' + data, 'Print', 'left=200, top=200, width=950, height=500, toolbar=0, resizable=0');
I really do appreciate any help.. because i am new to java script and asp.net. Sorry for my English.