function KeyUpEvent() { var txt1 = document.getElementById("txt1"); var txt2 = document.getElementById("txt2"); var txt3 = document.getElementById("txt3"); if ((txt1.value != "") && (txt2.value != "")) { txt3.value = parseInt(txt1.value) + parseInt(txt2.value); } }
<asp:TextBox ID="txt1" runat="server"></asp:TextBox> <asp:TextBox ID="txt2" runat="server"></asp:TextBox> <asp:TextBox ID="txt3" runat="server"></asp:TextBox>
txt1.Attributes.Add("onKeyUp", "javascript:KeyUpEvent();"); txt2.Attributes.Add("onKeyUp", "javascript:KeyUpEvent();");