Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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.
Posted
Updated 24-Jul-17 11:48am
Comments
[no name] 22-May-13 8:33am    
What was wrong with the answers that you have already gotten for this exact same "question"?
Computer Wiz99 22-May-13 8:35am    
You called it spam and closed my question before I was able to read it!!!
[no name] 22-May-13 8:44am    
Uhmmm..... no I did not.
Computer Wiz99 22-May-13 8:52am    
I got an email with your name in it along with ryanb31 and Sergey Alexandrovich Kryukov. And other emails where you guys have closed my questions!!

Here is the email:

Your question 'Auto calculation using textboxes in ASP.NET' has been reported by Sergey Alexandrovich Kryukov, ryanb31, ThePhantomUpvoter and has been closed, with the reason being given as This post is spam, abusive or otherwise inappropriate.

If you wish to revise and reopen your article based on the feedback from these members then simply go to Auto calculation using textboxes in ASP.NET and click the "Update my article" link. This will enable you to edit and update your article and will re-open your article for other members to enjoy.
[no name] 22-May-13 9:00am    
Then you need to read it again. It was not closed as "spam" it was closed because it was not a question. You have not shown any effort to solve this yourself, you have a history of asking the exact same questions over and over and over (abuse) and the only thing that you have asked here is "gimme code".

1 solution

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

C#
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); 

    }
}
 
Share this answer
 
Comments
Maciej Los 22-May-13 16:15pm    
What would happen if i enter decimal value?
KK Kod 23-May-13 4:00am    
you can also youse some client side script and write calculation code in text change or on blur event of the second or final text box to do calculation and display in the answer text box .
the above method you adopted is good but a post back will happen for one simple calculation i think dont let that happen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900