模式窗口是一種方便的當前頁面擴展的方式,但是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):
<html>
<head>
<script language="javascript">
function resolveurl()
{
var frm = window.frames[0];
frm.location = location.tostring().replace("c.htm","c.aspx");
}
</script>
</head>
<body >
<table align="left" cellpadding="0" cellspacing="0" id="table1">
<tr>
<td valign="top"><iframe id="ifmain"></iframe></td>
</tr>
</table>
</body>
</html>
3.aspx文件(searchitemc.aspx)代碼:
request.querystring["sysid"].trim();