2016-08-05 1 views
0

asp : aspx 페이지에 asp : textbox를 선언했습니다.ASP의 BackgroundColor 변경 : TEXTBOX via javascript

<asp:TextBox ID="txta" runat="server" size="12" value="123"></asp:TextBox> 

나는 HEADER에서 자바 스크립트 기능이 : 제어 losts가 초점을 맞출 때

는 경고가
txta.Attributes.Add("onblur", "changeColor();") 

입니다 :이 같은 ASP를 제어 특성 및 onblur에 합류

Page_Load 이벤트에
<head runat="server"> 
<title>My Page</title> 

<script type = "text/javascript" > 

    function changeColor() { 
     document.getElementById('<%= txta.ClientID %>').backgroundColor="#FF0000"; 
     alert('<%= txta.ClientID %>'); 
    } 
</script> 

</head> 

을 표시되지만 배경색은 변경되지 않습니다.

어떻게해야합니까?

답변

3

document.getElementById('<%= txta.ClientID %>').style.backgroundColor = "#FF0000";을 사용하십시오.

.style을 잊어 버렸습니다.