parent.aspx 做为父页,html 端代码如下:
<script language="javascript">
function select_value()
{
var val = document.getElementById("StrCode").value;
var text = document.getElementById("StrName").value;
var returnvalue = showModalDialog("StreetTreeViewModule.aspx?selectval="+val+"&selecttext="+text,"","dialogHeight:500px;dialogWidth:580px");
if(returnvalue == undefined){ return false;}
document.getElementById("StrCode").value = returnvalue[1];
document.getElementById("StrName").value = returnvalue[3];
document.getElementById("Textbox17").value = returnvalue[2]+">>"+returnvalue[3];
}
</script>
function select_value()
{
var val = document.getElementById("StrCode").value;
var text = document.getElementById("StrName").value;
var returnvalue = showModalDialog("StreetTreeViewModule.aspx?selectval="+val+"&selecttext="+text,"","dialogHeight:500px;dialogWidth:580px");
if(returnvalue == undefined){ return false;}
document.getElementById("StrCode").value = returnvalue[1];
document.getElementById("StrName").value = returnvalue[3];
document.getElementById("Textbox17").value = returnvalue[2]+">>"+returnvalue[3];
}
</script>
<table>
<TR>
<TD>街路:</TD>
<TD colSpan="5">
<INPUT id="StrCode" type="hidden" size="20" name="StrCode" runat="server"> <INPUT id="StrName" type="hidden" size="20" name="StrName" runat="server">
<asp:TextBox id="Textbox17" runat="server" ReadOnly="True"></asp:TextBox> <INPUT name="cat" onclick="select_value()" type="button" value="选择街道"> (为了房源能更容易被人搜索到,请选择街路)</TD>
</TR>
</table>
<TR>
<TD>街路:</TD>
<TD colSpan="5">
<INPUT id="StrCode" type="hidden" size="20" name="StrCode" runat="server"> <INPUT id="StrName" type="hidden" size="20" name="StrName" runat="server">
<asp:TextBox id="Textbox17" runat="server" ReadOnly="True"></asp:TextBox> <INPUT name="cat" onclick="select_value()" type="button" value="选择街道"> (为了房源能更容易被人搜索到,请选择街路)</TD>
</TR>
</table>
当点击了按钮 "选择街道" 后会调用上面的 js 函数
弹出的 StreetTreeViewModule.aspx 的 html 端代码如下:
<base target="_self">
<SCRIPT language="JavaScript">
<!--
function retForm(AreaID,StreetID,AreaName,StreetName)
{
var members = new Array();
members[0] = AreaID;
members[1] = StreetID;
members[2] = AreaName;
members[3] = StreetName;
window.returnValue = members;
window.close();
}
//-->
</SCRIPT>
<SCRIPT language="JavaScript">
<!--
function retForm(AreaID,StreetID,AreaName,StreetName)
{
var members = new Array();
members[0] = AreaID;
members[1] = StreetID;
members[2] = AreaName;
members[3] = StreetName;
window.returnValue = members;
window.close();
}
//-->
</SCRIPT>
<asp:DataList id="DataList1" RepeatColumns="6" RepeatDirection="Horizontal" runat="server" Width="100%">
<ItemTemplate>
<table width="100%" align="center">
<tr>
<td align="left" width="17%"><a href="" onClick="retForm('4','<%# DataBinder.Eval(Container.DataItem,"StreetCode" ) %>','昌邑区','<%# DataBinder.Eval(Container.DataItem,"StreetName" ) %>')"><%# DataBinder.Eval(Container.DataItem,"StreetName" ) %></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<ItemTemplate>
<table width="100%" align="center">
<tr>
<td align="left" width="17%"><a href="" onClick="retForm('4','<%# DataBinder.Eval(Container.DataItem,"StreetCode" ) %>','昌邑区','<%# DataBinder.Eval(Container.DataItem,"StreetName" ) %>')"><%# DataBinder.Eval(Container.DataItem,"StreetName" ) %></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
当点击了 DataList1 中的连接后,会调 用 js 函数中的 retForm 方法,把参数传回到父页 parent.aspx 中去。
如果 StreetTreeViewModule.aspx 中再打开一个模态窗口 child.aspx ,要想实现同样的传值效果,按同样方法就可以。