Solved

Performing Math Calculations on TextBox Contents

Posted on 2008-11-01
2
449 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:Carla Romere
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22858461
are you sure this is the code and you are not missing anything
because by just having a look at your code i can see that the code should not compile
modify your code as i have shown below

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

Author Comment

by:Carla Romere
ID: 22858630
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

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question