问题
Hi I have a web app which has a listbox of all the available reports for a particular user. I want to open a new page 'ReportViewerPane' when a row is clicked and pass the report name and some parameters through to the reportviewer.aspx I then need to set the ReportViewer controls .reportpath to the correct (passed through) value and set the parameters values (also passed through).
I the moment I have this in the parent page. 'PassParmString' is a textbox on the main form:
function open_win()
{
var Parms = document.getElementById('<%=PassParmString.ClientID %>');
window.open("ViewerPane.aspx?prm=" + Parms,"_blank","left=20,top=20,width=1000,height=1140,toolbar=0,resizable=1");
}
</script>
but have no idea how to access the parameter 'Parms'
that I pass once I am in in the ReportViewer.aspx form.
Please help.
I'm not good at this. And really trying to understand the posts so please be patient.
Many thanks
Mac
回答1:
you can get it using regular request querystring collection in your ViewerPane.aspx
page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If NOT IsPostBack
If Not String.IsNullOrEmpty(Request.QueryString("prm"))
string querystringvalue = Request.QueryString("prm").ToString()
End If
End If
End Sub
try changing your javascript to this
<script>
function open_win()
{
var Parms = document.getElementById('<%=PassParmString.ClientID %>');
window.open("ViewerPane.aspx?prm=" + Parms.value,"_blank","left=20,top=20,width=1000,height=1140,toolbar=0,resizable=1");
}
</script>
See if this helps :)
回答2:
u are passing the element, and not its value, u can do something like this :
Parms = document.getElementById('PassParmString').value;
来源:https://stackoverflow.com/questions/10224407/open-a-new-window-and-pass-parameters-to-it-vb-net-asp