Problem using calculator

admin

Administrator
Staff member
I’m not sure if anyone can help, but I'm trying to use a feature covered in the SAMS Publishing “ASP.NET 2.0 in 24 Hours” book.

I’m trying to use the Financial Calculator outlined in the book for a website I’m building. I have got the calculator to work by following the steps in the book (see attached FinancialCalculator.zip code)

But when trying to use it in the website I’m building, it won’t work. This website I’m building uses a master page. I have attached my code for this as well (ComLoans.zip)

The error I am getting is:

Compiler Error Message: BC30311: Value of type 'Double' cannot be converted to 'System.Web.UI.WebControls.Label'.


(screenshot of error attached)

.. which is related to me trying to display the result in a label web control when the user submits it. I don't understand why this is happening upon loading the page, because this event shouldn't occur until the user clicks the button.

I am using Microsoft's Visual Web Developer Express 2005 (<!-- m --><a class="postlink" href="http://msdn.microsoft.com/vstudio/express/vwd/">http://msdn.microsoft.com/vstudio/express/vwd/</a><!-- m -->) to build this site.

I have attached the code rather than post it in code boxes here because there is a lot of it. ;)I've spotted my error now. The last line of code for displaying the result in the label should be:


lblRepay.Text = costPerMonth


and not


lblRepay = costPerMonth


I also added the below code because the result was giving the answer in about 8 decimal places. :)


costPerMonth = Math.Round(costPerMonth, 2)lblRepay.Text = costPerMonth.ToString()
 
Back
Top