我的需求是这样的:
从弹出窗体中返回一个值,通过调用js赋给父窗体的一个TextBox,然后根据这个TextBox中的内容,再调用函数从数据库中查询其他数据,赋值给一个DropDownList,可是现在无法触发TextBox的TextChanged事件,不知有什么好办法?

解决方案 »

  1.   

    可以用javascript来做啊,用confirm()方法
      

  2.   

    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
    AutoPostBack设为true
    OnTextChanged只能在失去焦点时触发:
    试试在弹出窗体js赋值时,parent.document.getElementById("TextBox1").blur();
      

  3.   

    写错了window.opener.document.getElementById("TextBox1").blur();
      

  4.   


    父页面:
    function showChild()
        {
            var url = "Test.aspx";
            var width=600;
            var height=500;
            var retValue = window.showModalDialog(url, "", "dialogWidth:"+width+"px;dialogHeight:"+height+"px;status:yes;directories:yes;scrollbars:yes;Resizable=yes;");
            if( retValue != null )
            {
                document.getElementById("TextBox1").value = retValue;
            }
        }
    子页面:
    function ReturnValue()
        {
            var txtvalue=document.getElementById("Text1");
            window.returnValue = retArr;
            self.close();
        }
      

  5.   

    获取到的值用ajax异步获取数据库数据绑定
             <select id="Select1">
                <option></option>
            </select>
      

  6.   

    因为回发了.TextBox1控件要为空了
     protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        static string  a = "" ;
     
        protected void Button1_Click(object sender, EventArgs e)
        {
            a = "1";
        }
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
           string strCnn = "Data Source=.;Initial Catalog=book;Integrated Security=True;";
            SqlConnection ACconn = new SqlConnection(strCnn);
            string ACsql = "select *from book where id='" + a + "'";        SqlDataAdapter da = new SqlDataAdapter(ACsql, ACconn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }可以参考一下!