我是新手,需要实现DropDownList1选择的内容在TextBox1中显示,同时触发TextBox1_TextChanged事件,而DropDownList1的AutoPostBack属性只能为False我在html里给DropDownList1加了一个onchange="change()"又在js里写了一个函数
function change()
   { 
      var str
      str =window.document.Form1.DropDownList1.options[Form1.ddlProduct.selectedIndex].value;
      window.document.Form1.TextBox1.value=str;
    }
我希望TextBox1的内容改变时触发TextBox1_TextChanged事件,请问有什么方法么?
有人说可以加隐藏控件,怎么加啊?

解决方案 »

  1.   

    在TEXbOX1的HTML里加 onChange="yourFunction();"然后定义yourFunction()就可以了
      

  2.   

    如果后台添加了TextBox1的TextChanged事件的话,前台改变了text的值就应该会触发后台的方法。
    如果还是没有触发,就在方法体里面调用__doPostBack
    function change()
       { 
          var str
          str =window.document.Form1.DropDownList1.options[Form1.ddlProduct.selectedIndex].value;
          window.document.Form1.TextBox1.value=str;
          __doPostBack('TextBox1','');
        }
      

  3.   

    to:Zoujinyucn
    我添加了__doPostBack('TextBox1','');显示页面错误阿,提示缺少对象
      

  4.   

    to: MEETIN2006
    TextBox1_TextChanged事件需要调用数据库,在前台里写不了啊。
      

  5.   

    添加了__doPostBack('TextBox1','');
    可以实现,刚才我自己写错了,谢谢Zoujinyucn结贴给分