V
vinnie
i'm very new to asp.net-C# and since i want to learn it, i was just
trying to make this page to work, but i get an error message that says
"Error 1 The name 'US' does not exist in the current context C:\PATH-
TO-MY-PAGE\CurrencyConverter.aspx.cs 18 42"
These are the two files:
a) the aspx is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" method="post" runat="server">
<div>
Convert <input id="US" type="text" /> US
Dollar in Euro
<input id="Convert" type="submit" value="ok" /></div>
<div style="font-weight:bold"; ID="Result" runat="server">
</div>
</form>
<p>
</p>
</body>
</html>
b) the aspx.cs is:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
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;
using System.Xml.Linq;
public partial class CurrencyConverter : System.Web.UI.Page
{
protected void Convert_ServerClick(object sender, EventArgs e)
{
decimal USamount = decimal.Parse(US.Value);
decimal Euro = USamount * 1.30M;
Result.InnerText = USamount.ToString() + "US Dollars = ";
Result.InnerText += Euro.ToString() + "Euro ";
}
}
What's wrong?
trying to make this page to work, but i get an error message that says
"Error 1 The name 'US' does not exist in the current context C:\PATH-
TO-MY-PAGE\CurrencyConverter.aspx.cs 18 42"
These are the two files:
a) the aspx is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" method="post" runat="server">
<div>
Convert <input id="US" type="text" /> US
Dollar in Euro
<input id="Convert" type="submit" value="ok" /></div>
<div style="font-weight:bold"; ID="Result" runat="server">
</div>
</form>
<p>
</p>
</body>
</html>
b) the aspx.cs is:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
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;
using System.Xml.Linq;
public partial class CurrencyConverter : System.Web.UI.Page
{
protected void Convert_ServerClick(object sender, EventArgs e)
{
decimal USamount = decimal.Parse(US.Value);
decimal Euro = USamount * 1.30M;
Result.InnerText = USamount.ToString() + "US Dollars = ";
Result.InnerText += Euro.ToString() + "Euro ";
}
}
What's wrong?