本帖最后由 yinyuan1987 于 2009-09-12 11:00:53 编辑

解决方案 »

  1.   

    对4个textbox赋值时,4个都获取到值,而且弹出窗口也正常关闭了吗?
      

  2.   

    能获取到值,也能关闭,但是在弹出窗口的其他事件不能相应了
    只对一个textBox赋值可以使用,2个以上就不可以了
      

  3.   

    试一试这两种方法
    1. 在调用方写一个script函数,由被调用方调用调用方:
    <script language="javascript">
    function assignToTB(QRFNoVal, CustVal) { 
    var QRFNo = document.getElementById('QRFNo'); 
    QRFNo.value = QRFNoVal;

    var CustCode = document.getElementById('Customer'); 
    CustCode.value = CustVal; 

    </script> 被调用方:
    <script language="javascript">
    function ReturnValue(QRFNo, CustCode) 

    self.opener.assignToTB(QRFNo, CustCode);
    self.close(); 
    return false; 

    </script>2.在被调用方试一试下面的格式:
    Function close(value){window.opener.document.forms[0].TextBox1.value = value;window.close();}参考:
    http://forums.asp.net/p/1361735/2814234.aspx
      

  4.   

    首先谢谢楼上朋友的回答第一种方法在对我情况不适合,我是在GridView行内数据绑定里定义的,也就是在后台Code里的第二种方法我加上了forms[0]之后,还是一样
      

  5.   

    你把Open窗口的代码贴出来看看,我在机子上试过的,没有问题。
      

  6.   


    protected void gvMessageEmp_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //设置行颜色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='lightblue'");            //添加自定义属性,当鼠标移走时还原该行的背景色            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");            //实现双击某一行后,动态更新工资页面的信息;
                Session["SelectEmpID"] = e.Row.Cells[0].Text.ToString().Trim();
                Session["SelectEmpName"] = e.Row.Cells[1].Text.ToString().Trim();
                Session["SelectDepID"] = e.Row.Cells[2].Text.ToString().Trim();
                Session["SelectDepName"] = e.Row.Cells[3].Text.ToString().Trim();            string jsString = "window.opener.document.getElementById('txtEmpId').value='" + Session["SelectEmpID"] + "';window.opener.document.getElementById('txtEmpName').value='" + Session["SelectEmpName"] + "';window.opener.document.getElementById('txtDepId').value='" + Session["SelectDepID"] + "';window.opener.document.getElementById('txtDepName').value='" + Session["SelectDepName"] + "';window.close();";
                e.Row.Attributes.Add("ondblclick", jsString);
            }
        }
        protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            string empId = txtEmpID.Text.Trim();
            int depId = Convert.ToInt32(ddlDepart.SelectedValue);        DataSet ds = new DataSet();
            if (empId != "" && empId != null)
            {
                ds = HRH_MessageEmpManager.GetHRH_MessageEmp(empId, depId);
            }
            else
            {
                ds = HRH_MessageEmpManager.GetHRH_MessageEmp(depId);
            }        gvMessageEmp.DataSourceID = null;
            gvMessageEmp.DataSource = ds;
            gvMessageEmp.DataBind();
        }
    页面上就只有一个TextBox让用户输入员工编号
    和一个下拉列表选择部门
    还有一个查询按钮,就是想点击查询按钮显示相应的记录
      

  7.   

    你的txtEmpName有没有runat=server的?
    如果是服务器控件,用txtEmpName在js里找应该是找不到的,要用ClientID
      

  8.   

    呵呵,现在txtEmpName都可以的获取值,就是open出来窗口的其他事件没法响应
      

  9.   

    imgbtnSearch_Click事件不执行,事件是否丢失
      

  10.   

    private BibdData()
    {
    string empId = txtEmpID.Text.Trim();
            int depId = Convert.ToInt32(ddlDepart.SelectedValue);        DataSet ds = new DataSet();
            if (empId != "" && empId != null)
            {
                ds = HRH_MessageEmpManager.GetHRH_MessageEmp(empId, depId);
            }
            else
            {
                ds = HRH_MessageEmpManager.GetHRH_MessageEmp(depId);
            }        gvMessageEmp.DataSourceID = null;
            gvMessageEmp.DataSource = ds;
            gvMessageEmp.DataBind();
    }
     protected void imgbtnSearch_Click(object sender, ImageClickEventArgs e)
        {
       BindData();
    }
    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    BindData(); }
            }
      

  11.   

    <ItemTemplate>
    <tr>
    <td align="center" onclick="javascript:SetValue('<%#  Eval("Id")%>','<%#Eval("Name")%>','<%#Eval("DeptID")%>','<%#Eval("DeptName")%>')" style="cursor: pointer; cursor: hand;" onmouseover="b_on(this)" onmouseout="b_off(this)"><%#Eval("Name")%></td>
    </tr>
    </ItemTemplate>
       var p_window;
          if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1)
              p_window = window.parent.opener;
          else
              p_window = window.parent.opener; 
          function b_on(target) {
              color = "lightblue";
              target.style.borderColor = "black";
              target.style.backgroundColor = color;
              target.style.color = "white";      }
          function b_off(target) {
              target.style.backgroundColor = "";
              target.style.borderColor = "";
              target.style.color = "";
              target.style.fontWeight = "";
          }
          function SetValue(id, name, deptid,deptname) {
              p_window.document.getElementById("txtEmpId").value = id;
              p_window.document.getElementById("txtEmpName").value =name;
              p_window.document.getElementById("txtDeptId").value = deptid;
              p_window.document.getElementById("txtDeptName").value = deptname;
              self.close();
          }
      

  12.   

    是的,open出的窗口的其他事件都不执行
    后台代码有事件的相关处理代码
      

  13.   

    谢谢wuyq11,我先试试修改代码
      

  14.   

    呵呵,谢谢大家的回复,问题解决了,是get和post 请求方法的问题默认使用的get,四个参数放在请求头中,数据量太大了把form 的method改为post就OK了!