beginning

V

vinnie

i did this simple page, but i don't see the results, why?

A) asp.net-C# file is:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="CurrencyConverter.aspx.cs" Inherits="CurrencyConverter" %>

<!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>
<script language="javascript" type="text/javascript">
// <!CDATA[


// ]]>
</script>
</head>
<body>
<form id="form1" method="post" runat="server">
<div>

Convert&nbsp;<input id="US" type="text" runat="server" /
&nbsp;&nbsp;US Dollar in Euro&nbsp;&nbsp;

<input id="Convert" type="submit" value="ok" onclick="return
Convert_onclick" runat="server" /><br />
<br />
</div>
<div style="font-weight: bold" ID="Result" runat="server"></div>
</form>
<p>
&nbsp;</p>
</body>
</html>


B)the aspx.cs file 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????
 
A

Alberto Poblacion

vinnie said:
i did this simple page, but i don't see the results, why?
[...]
<input id="Convert" type="submit" value="ok" onclick="return
Convert_onclick" runat="server" /><br />
[...]
protected void Convert_ServerClick(object sender, EventArgs e)
[...]
what's wrong????

You have not connected your Submit button to the Convert_ServerClick
server method. Instead, you have added an "onclick", probably with the
intention of writing a client-side method "Conver_onclick", which your code
doesn't contain, either.

Easiest fix: Remove the onclick attribute, switch to design mode, and
double-click the button to generate the server click event. Then move the
code in Convert_ServerClick to the method that was autogenerated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top