不要用服务器控件,改用input

解决方案 »

  1.   

    请用Control.ClientID 属性 
      

  2.   

    应该是差一个引号
    document.getElementById('+lblID+').className='ErrMsgArea'; 
      

  3.   

    Label12根本没有。。
     <asp:Label ID="Label12" runat="server" Text="Label">123</asp:Label>
    加上去就好了
      

  4.   

    onfocus="javascript:txtfocus('<%=this.ClientID%>','<%=Label12.ClientID%>');"
      

  5.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <script language="javascript" type="text/javascript"> 
            function txtfocus(lblID,txtID) 
            { 
            document.getElementById(lblID).className='ErrMsgArea'; 
            document.getElementById(txtID).style.background = 'red'; 
            return false; 
            } 
        </script> 
    <asp:TextBox ID="txtReUsrName" runat="server" Height="19px" CssClass="txtOnFocus" onfocus="javascript:txtfocus('txtReUsrName','Label12');"> </asp:TextBox> 
    <asp:Label ID="Label12" runat="server" Text="Label">123</asp:Label>
        </form>
    </body>
    </html>
    IE7下么得问题!