你的this.TextBox1.Attributes.Add("onkeyup","__doPostBack('"+this.UniqueID+"_TextBox1,'')");
这段代码是否放在了 if(!Page.IsPostBack)块中了?应该放在外面。另外注册回发脚本应该用 Page.GetPostBackEventReference()方法,而不是直接将 __doPostBack()这个asp.net页框架自动产生的客户端脚本加到代码中,因为如果你的页面上没有LinkButton或者Button等需要调用这个脚本来回的的控件,asp.net页框架就不会产生这个脚本,因此你的代码就无法运行,你可以把上面的代码改成这样:this.TextBox1.Attributes.Add("onkeyup",Page.GetPostBackEventReference(this.TextBox1));

解决方案 »

  1.   

    it is really a bad idea to do postback on each onkeyup, there is a good reason why ASP.NET doesn't offer those client side events as server events, because the page will flicker like hell, your users will complain but if you insist, try to implement the er interface INamingContainer (no method needs to be implemented):class YourControl : ...., INamingContainer
      

  2.   

    这样按键刷新的确不是一个好的办法,来回刷新会让人受不了的。
    可以用xmlhttp的方法。