Passing value from parent form to .NET control via javascript. Gridview Selectparameter from window.opener
I have two asp.net forms.
The first form opens a popup window to the second using onclick javascript as follows:
onclientclick="javascript:PS=window.open('https://site/PS.aspx','PS','width=800,height=600,scrollbars=1');PS.focus()"
the second form has a .net gridview with a SelectParameter.
<Select开发者_开发问答Parameters>
<asp:ControlParameter ControlID="???" Name="FirstName" DefaultValue="=" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
How can I set the value of the parameter to the value of control on the parent form? I don't want to use a session variable or a querystring if possible.
Thanks.
You should be able to pull a value from the parent window like this:
On the parent form, add a hidden field and create a function like this to access it's value:
getParameterValue = function(){
return document.getElementById("<%=HiddenCtrl.UniqueID%>").value;
}
Add a hidden field in the child window too, and set the value like this:
document.getElementById("<%=ChildHiddenCtrl.UniqueID%>").value = window.opener.getParameterValue();
And then for your control parameter, use ChildHiddenCtrl:
<asp:ControlParameter ControlID="ChildHiddenCtrl" ... >
精彩评论