模式窗口是一种方便的当前页面扩展的方式,但是aspx文件只能作为HTM文件的IFRAME才能用这种方式调用。同时,请求字符串也是一种方便常用的页面间传值的方法,那么怎么样使两者给合起来,就是实现如何用请求字符串传值给用模式窗口打开的aspx页面呢?
我们可以用JS脚本实现这种功能:
1.调用页面代码:
<script language="javascript"> function GetCorrelativeItemId() { rdl = document.getElementsByName("rdlSystem"); input = document.getElementById("txtCorrelativeItem"); sysid = ""; for(i = 0 ; i < rdl.length ; i++) { if(rdl[i].tagName == "INPUT") { if(rdl[i].checked) { sysid = rdl[i].value; } } } arg = window.showModalDialog("SearchItemC.htm?sysid="+sysid,window,"resizable:1;"); if(arg!=null) { input.value = arg; } } </script>
2.打开的HTM文件的代码(SearchItemC.htm):
<script language="javascript" type="text/javascript"> function ResolveUrl() { var frm = window.frames[0]; frm.location = location.toString().replace("C.htm","C.aspx"); } </script> <HTML> <HEAD> <script language="javascript"> function ResolveUrl() { var frm = window.frames[0]; frm.location = location.toString().replace("C.htm","C.aspx"); } </script> </HEAD> <BODY style="margintop:0;marginleft:0;marginright:0;marginbottom:0" οnlοad="ResolveUrl()"> <table align="left" cellpadding="0" cellspacing="0" width="100%" height="100%" ID="Table1"> <tr> <td valign="top" width="100%" height="100%"><iframe id="ifmain" border="0" width="100%" height="100%"></iframe></td> </tr> </table> </BODY></HTML>
3.Aspx文件(SearchItemC.aspx)代码:
Request.QueryString["sysid"].Trim();<script language="javascript" type="text/javascript"> function GetCorrelativeItemId() { rdl = document.getElementsByName("rdlSystem"); input = document.getElementById("txtCorrelativeItem"); sysid = ""; for(i = 0 ; i < rdl.length ; i++) { if(rdl[i].tagName == "INPUT") { if(rdl[i].checked) { sysid = rdl[i].value; } } } arg = window.showModalDialog("SearchItemC.htm?sysid="+sysid,window,"resizable:1;"); if(arg!=null) { input.value = arg; } } </script><script language="javascript" type="text/javascript"> function GetCorrelativeItemId() { rdl = document.getElementsByName("rdlSystem"); input = document.getElementById("txtCorrelativeItem"); sysid = ""; for(i = 0 ; i < rdl.length ; i++) { if(rdl[i].tagName == "INPUT") { if(rdl[i].checked) { sysid = rdl[i].value; } } } arg = window.showModalDialog("SearchItemC.htm?sysid="+sysid,window,"resizable:1;"); if(arg!=null) { input.value = arg; } } </script><script language="javascript" type="text/javascript"> function GetCorrelativeItemId() { rdl = document.getElementsByName("rdlSystem"); input = document.getElementById("txtCorrelativeItem"); sysid = ""; for(i = 0 ; i < rdl.length ; i++) { if(rdl[i].tagName == "INPUT") { if(rdl[i].checked) { sysid = rdl[i].value; } } } arg = window.showModalDialog("SearchItemC.htm?sysid="+sysid,window,"resizable:1;"); if(arg!=null) { input.value = arg; } } </script><script language="javascript" type="text/javascript"> function GetCorrelativeItemId() { rdl = document.getElementsByName("rdlSystem"); input = document.getElementById("txtCorrelativeItem"); sysid = ""; for(i = 0 ; i < rdl.length ; i++) { if(rdl[i].tagName == "INPUT") { if(rdl[i].checked) { sysid = rdl[i].value; } } } arg = window.showModalDialog("SearchItemC.htm?sysid="+sysid,window,"resizable:1;"); if(arg!=null) { input.value = arg; } } </script>