txtsales和txtother两个TextChange事件中的代码一样,{
 double sales=System.Double.Parse(txtsales.Text);
 double other=System.Double.Parse(txtother.Text);
//不过在这之前要判断两个文本框中的内容是否为空,如果为空的话,将sales或other赋0值;
 double sum=sales+other;
 txtsum.Text=sum.ToString();
}

解决方案 »

  1.   

    用javascript
    textbox的客户端onchange事件
      

  2.   

    javascript<input name="txtsales" onkey="formname.txtsum.value='this.value+txtother.value'">
    <input name="txtother" onkey="formname.txtsum.value='this.value+txtsales.value'">不知道是不是onkey事件,反正代码是这样写的。复杂一点是这样<input name="txtsales" onkey="sums()">
    <input name="txtother" onkey="sums()"><script>
    function sums(){    if(txtsales.value != "" && txtother.value=='')
        {
             txtsum.value = txtsales.value
        }else{
             txtsum.value = txtsales.value + txtother.value
        }
    }</script>我这里没有判断是否为数字!