Have you able to figure this out yet?
I had a same issue even I used the same code I downloaded from the site.
Even though I put the calculator.cs under App_code foler, The caculator class doesn't get defined.
Any ideas?
/App_code/Calculator.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class Calculator
{
public int Add(int a, int b)
{
return (a + b);
}
public int Subtract(int a, int b)
{
return (a - b);
}
}
Default.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="Server">
protected void Page_Load(Object sender, EventArgs e)
{
Calculator myCalc = new Calculator();
Label1.Text = myCalc.Add(12, 12).ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
|