我可以在ASP.NET中使用文本框自动计算吗? [英] Can I use Auto calculation using textboxes in ASP.NET?

查看:136
本文介绍了我可以在ASP.NET中使用文本框自动计算吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了3个文本框,想知道是否有一个简单的代码可用于添加,减去和使用这些texbox的其他数学事物。我想要做的是让文本框在tectboxes中进行自动计算。我在一个文本框中输入数字,在另一个文本框中输入数字,第三个文本框将有答案。有人可以提供示例代码吗?谢谢。

I have created 3 textbox and wanted to know is there a simple code I can use to add, subtract, and other math things with these texboxes. What I wanted to do is to have the textboxes to do auto calculations within the tectboxes. I enter numbers in one textbox and numbers in the other and the third textbox will have the answer. Can someone give a sample code? Thanks.

推荐答案

我自己解决了。我更改了代码并添加了一个按钮并将此代码放入:



I solved it myself. I changed the code and just added a button and put this code in:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Text;



public partial class FinancialIndicatorsFormA : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonCalculate_Click(object sender, EventArgs e)
    {
        int a = Convert.ToInt32(TextBoxTA.Text);
        int b = Convert.ToInt32(TextBoxTL.Text);
        TextBoxTNA.Text = Convert.ToString(a - b); 

    }
}


这篇关于我可以在ASP.NET中使用文本框自动计算吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆