Link to home
Start Free TrialLog in
Avatar of Carla Romere
Carla RomereFlag for United States of America

asked on

Performing Math Calculations on TextBox Contents

I have a couple of text boxes on a form that I want to take the contents, perform one mathematical calculation against it and set the contents of a label with the results. I'd like to have the label set upon exit of the text box field. The textbox name is txtOpBudgAmt and the drop down is ddlTime1.

I have attached my code in the OnTextChanged event for the textbox txtOpBudgAmt which isn't working. What am I doing wrong here?

if (ddlTime1.SelectedValue == "Week")
        {
            int intWeeklyAmt Convert Int32(txtOpBudgAmt) * 52;
            lblOpBudgCalcAmt = intWeeklyAmt.ToString();
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Carla Romere

ASKER

Okay - i modified your's slightly to the attached which works now. It refreshes the whole page which works, but is slightly annoying. So, I'm going to accept your solution and then try to figure out how to update the label without refreshing the entire page. Maybe an updatepanel...


     double dWeeklyAmt = Convert.ToDouble(txtOpBudgAmt.Text) * 52;
     lblOpBudgCalcAmt.Text = dWeeklyAmt.ToString();

Open in new window