在我的代码中有 private void dgItem_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
...
Response.Write("<script language='javascript'>window.opener.document.all('txtIM').value = '"+strItem +"';window.opener.document.all('txtDesign').value = '"+strDesiNo+ "';window.opener.document.all('txtDesc').value = '"+strDesc+"';window.close();</script>");
}
}
最后一句reponse.write在有的机器上能执行,有的不能,为什么,如何解决?

解决方案 »

  1.   

    不是有的机器执行,有的机器不执行,是有的机器它只是在左下角出一黄三角提示你JAVASCRIPT错误,但程序照执行。有的机器就直接弹出错误提示,所以你感觉有的出错,有的没错,其实都有错。
    你写的这段输出JAVASCRIPT代码有错误。
    试试这样,看看左下角还有没有脚本错误。没测试。
    Response.Write("<script>window.opener.document.all('txtIM').value = "+strItem +";window.opener.document.all('txtDesign').value = "+strDesiNo+ ";window.opener.document.all('txtDesc').value = "+strDesc+";window.close();</script>");
      

  2.   

    在同一台机器上
    private void btnSearch_Click(object sender, System.EventArgs e)
    {
    Response.Write("<script language='javascript'>alert('OK');</script>");
    }
    能执行
    private void dgItem_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    Response.Write("<script language='javascript'>alert('OK');</script>");
    }
    不能执行
      

  3.   

    估计是不能执行是那台电脑的IE设置问题.
    可能是版本低了!!!有可能是IE被设置过
      

  4.   

    private void btnSearch_Click(object sender, System.EventArgs e)
    {
    Response.Write("<script language='javascript'>alert('OK');</script>");
    }
    能执行
    private void dgItem_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    Response.Write("<script language='javascript'>alert('OK');</script>");
    }
    不能执行
    -------------------
    这是两个不同的事件,触发方式不一样,你能确保这两上事件都执行了吗?
    最简单的方法在两个事件的代码中按下F9,调试一下就知道了.
      

  5.   

    在我开发的电脑上,都无问题,移植到服务器上有dgItem_EditCommand中的任何Reponse.Write中的语句都不能执行,但同事用VB.net写的就可以,这已经困扰了我三个月,找不到原因
      

  6.   

    private void dgItem_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {this.RegisterClientScriptBlock("aa","<script language='javascript'>alert('OK');</script>");
    }