我想实现一个功能是在index.aspx点击一个按钮,然后跳出一个模式窗口,模式窗口里的是一个DataGrid,里面放的是员工的ID和NAME,我想把一点数据后,模式窗口自动关闭,数据返回上一个页面的一textbox中.我已经写了部分代码,但是不知道在模式窗口中该如何写代码,把数据传过来.
我的部分代码如下:
index.asp中
<input name="SPR" type="text" id="SPR" disabled style="WIDTH:58px"><input name="choiceSPR" id="choiceSPR" type="button"  onclick="javascript:selname()"  value="选择审批人">&nbsp;
<INPUT id="SPR_User" style="WIDTH: 0px; HEIGHT: 0px" type="hidden" size="1" name="SPR_User"><INPUT id="SPR_UserID" style="WIDTH: 0px; HEIGHT: 0px" type="hidden" size="1" name="SPR_UserID"></td>
<script language="VBScript">
    sub selname()
      selection = window.showModalDialog("name.aspx?depart=10","nnn","dialogleft=235;dialogWidth:290px;dialogHeight:420px;status=no;scroll=no;help=no;")
   if selection <> "" Then   &document.APPLY.DropDownList1.SelectedValue&
      TempArr = split(selection,"|")
      APPLY.SPR.value = TempArr(1)
   APPLY.SPR_User.value = TempArr(1)
      APPLY.SPR_UserID.value = TempArr(0)
   end if
    end sub
</script>在模式小窗口中:
<script language="javascript">
  function ReturnNote(CusID,CusName) 
  { window.opener.document.Form1.txtCustomerName.value=CusName;
   window.opener.document.Form1.txtCustomerID.value=CusID;
   var selection=new selection(CusID,CusName);
    window.returnValue=selection; 
    window.opener=null; window.close(); }
</script>
</HEAD>
<body onkeydown="if(event.keyCode==116){reload.click()}" MS_POSITIONING="GridLayout">
<A id="reload" style="DISPLAY: none" href="ren.aspx">reload...</A>**************
<form name="Form1" method="post" action="name.aspx" id="Form1" runat=server>
</form>
</body>
</HTML>
不知道如何在写其他需要的代码 有没有范例 我很急,谢谢拉!!

解决方案 »

  1.   

    这是在INDEX.APSX中打开模式窗口,用的是一个客户端的BUTTON
    <INPUT class="redButtonCss" style="WIDTH: 60px; HEIGHT: 20px" onclick="OpenCustomer()"
    type="button" value="选择客户" name="cmdCust">
    打开模式窗口
    function OpenCustomer()
    {
    var url="../Customers/CustomerInfo.aspx";
    var array=window.showModalDialog(url,'','scrollbars=yes,top=0,left=0,resizable=no,status=no,toolbar=no,menubar=no,location=no,width=600,height=650');
    document.getElementById("txtCustomerName").value=array[1];
    document.getElementById("txtCustomerID").value=array[0];
    }在模式窗口中的DATAGRID中设一个模板列,放一个客户端的BUTTON,设置ONCLICK事件
    onclick='ReturnNote(<%# DataBinder.Eval(Container,"DataItem.CustomerID")%>,"<%# DataBinder.Eval(Container,"DataItem.CustomerName")%>")'脚本,返回你所得到的值,一个编号,一个名字(一个整型,一个字符串)
    <script language="javascript">
    function ReturnNote(CusID,CusName)
    {
    var array=new Array(CusID,CusName);
    window.returnValue=array;
    window.opener=null;
    window.close();
    }
    </script>
      

  2.   

    1。Index.aspx中:
    string url = string.Format("模式窗口.aspx") ;
    string script = string.Format("<script language=javascript>window.open('"+url+"','','toolbar=0,status=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=0,width=600,height=400')</script>");
    Response.Write(script) ; 2.模式窗口.aspx中:
    将你点击的员工ID存储在 string empId里(让Index.aspx接收并做查询显示,建议不要直接传数据)
    string url = string.Format("Index.aspx?EmpID={0}",empId);
    string script = "<script language=javascript>opener.location='"+url+"';</script>" ;
    Response.Write(script) ;
    script ="<script language=javascript>window.close  ();</script>" ;
    Response.Write(script) ;3。Index.aspx中:
    然后在Index.aspx中收到员工ID,
    string s = Request.QueryString["EmpID"].ToString();
    然后用s去查询该员工的信息并显示。OK.
      

  3.   

    用js写返回值就可以了。或是弹出datadailog就可以。