我的父窗口Default.aspx 用  var strUrl = "ProductUpdate.aspx?ID=" + itemID;
                var returnValue = window.showModalDialog(strUrl, window, "resizable=no;dialogWidth:750px;dialogHeight:650px;status:no;help:no;"); 打开了一个子窗口当子窗口回传returnValue ="ok"时
在if (returnValue == "ok") {
                  //  var btnSearch = document.getElementById("<%=Button1.ClientID %>");
                 //      btnSearch.click();
                      return true;
                }触发服务器控件 <asp:Button ID="Button1" runat="server" Text="查询" onclick="Button1_Click" /></td> ,我用这种方法不行,请问怎么写?很急,在线等

解决方案 »

  1.   

    你看看 returnValue 获取到了没
      

  2.   

    在if (returnValue == "ok") {这之前先alert(returnValue);看看打出来的是什么?
    var btnSearch = document.getElementById("<%=Button1.ClientID %>");
    btnSearch.click();是可以用的
      

  3.   


    这个是肯定是执行不到服务器端事件的。。你可以改种方法嘛 .cs文件Load事件中if(!string.IsNullOrEmpty(Requst["returnValue "]))
    {
        if(Requst["returnValue "] == "ok")
        {
           //点击事件中执行的代码
        }
    }
      

  4.   


    <asp:Button ID="Button1" runat="server" Text="查询" onclick="Button1_Click" OnClientClick="return jsFunctionToShowDlg();" />
      

  5.   

    btnSearch.click()是应该可以的,
    你在Button1_Click里面写
    Response.Write("xx")
    看能打出吗
      

  6.   


    看错了把你JS代码,放在</body>标签之前
      

  7.   

    不行,没能执行if(!string.IsNullOrEmpty(Requst["returnValue "]))
      

  8.   

    能写全面一些么,我想是在javascript里直接调用的。
      

  9.   


    你的参数名是叫:returnValue?if(!string.IsNullOrEmpty(Requst["returnValue"])) 上面是不是多了个空格?
      

  10.   

    本帖最后由 net_lover 于 2012-03-27 16:29:18 编辑
      

  11.   

    直接用document.getElmentById("Button1").click();
      

  12.   

    如果单单加 Response.Write("asdasdsa"); 可以显示
    但是  public void Button1_Click(object sender, EventArgs e)
            {
                Response.Write("asdasdsa");
               if (this.ddlProductLine.Text.Trim() == "please choose")
                {
                    MorenBind(Convert.ToInt32(ViewState["PageIndex"]));
                }
                else
                {
                    if (this.ddlProductLine.Text.Trim() == "please choose" && this.ddlSuppliers.Text.Trim() != "please choose")
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择产品线');</script>");
                    }
                    else
                    {
                        if (this.ddlProductLine.Text.Trim() != "please choose" && this.ddlSuppliers.Text.Trim() == "please choose")
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择供应商');</script>");
                        }
                        else
                        {
                            Bind(Convert.ToInt32(ViewState["PageIndex"]));
                        }
                    }            }
               
            }
    就不显示response里的内容了
      

  13.   

    搞这么复杂干嘛,你要在js中触发服务器空间按钮的click事件,直接获得按钮的然后click()就OK了啊,
    如:$("#btnOK").click();要不要括号我不记得了,你试下就知道了