你在Windows程序中TextBox是没有Attributes这个属性的,Web程序中有

解决方案 »

  1.   

    Here: System.Web.UI.AttributeCollection
           WebControl.Attributes 属性  [C#]
    下面的示例阐释当 TextBox 控件失去焦点时,可以如何使用 WebControl 的 Attributes 属性运行 Javascript 命令。
    [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html>
     <head>
        <script language="C#" runat="server">
     
            void Page_Load(Object sender, EventArgs e) {
               TextBox1.Attributes["onblur"]="javascript:alert('Hello! Focus lost from text box!!');";    
            }
        </script>
     
     </head>
     <body>
        <h3>Attributes Property of a Web Control</h3>
     <form runat="server">
     
        <asp:TextBox id="TextBox1" columns=54 
         Text="Click here and then tap out of this text box" 
         runat="server"/>  
     
     </form>
     </body>
     </html>
      

  2.   

    这句是web的代码吧,楼主在winForm中用?winForm中加事件可以这么加的话,那真的要关注一下了。
    这句的效果在网页中就会是这样
    <input name="TextBox1" type="text" id="TextBox1" onblur="document.all.Button1.click()" />
    onblur时就会触发Button1的click
      

  3.   

    Attributes是webcontrol的属性,因为textbox是继承自webcontrol,所以你要查webcontrol的所有成员就能查到
      

  4.   


    楼主应该是web中的代码,搜索 TextBox 类,你会看到这个属性
      

  5.   

    这个是web下的代码,功能应该是在textBox获得焦点时作些动作