各位仁兄:
    我想在<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox> 这个文本框得到焦点的时候让他的背景变成
    blue,各位帮帮忙把,我承认我很菜的(不过不要让我用  <input id="Text1" type="text" />html的控件!!在线急等!!!
 

解决方案 »

  1.   

      我想在 <asp:TextBox   ID= "TextBox1 " onmouseover="this.style.backgroundColor='#FF6600'" onmouseout="this.style.backgroundColor=''"  runat= "server "   > </asp:TextBox> 
      

  2.   

        <form id="form1" runat="server" defaultbutton="button1" defaultfocus="txtlabel">
      

  3.   

    <asp:TextBox ID="txt_userName" runat="server" Width="157px" onMouseOver="this.style.background='#E1F4EE';" onMouseOut="this.style.background='#FFFFFF'" onFocus="this.select(); "></asp:TextBox>大概就是这样 
      

  4.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>aa</title>
        <script type="text/javascript">
            function setcolor(obj)
            {
                obj.style.backgroundColor='blue';
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server" onfocus="setcolor(this)"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></div>
        </form>
    </body>
    </html>
      

  5.   

    protected void Page_Load(object sender, EventArgs e)
        {
            checkstatus();
        }
        protected void checkstatus()
        {
            for (int i = 0; i < form1.Controls.Count; i++)
            {
                if (form1.DefaultFocus == form1.Controls[i].ID)
                {
                    switch (form1.Controls[i].GetType().Name)
                    {
                        case "TextBox":
                            TextBox tb = form1.Controls[i] as TextBox;
                            tb.BackColor = System.Drawing.Color.Blue;
                            break;
                    }
                }
            }
        }
      

  6.   

    直接用个CSS样式不就得了,又简单又方便