62,046
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<!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>
<title>Currency Converter</title>
</head>
<body>
<form runat="server">
<div style="border-right: thin ridge; padding-right: 20px; border-top: thin ridge;
padding-left: 20px; padding-bottom: 20px; border-left: thin ridge; width: 531px;
padding-top: 20px; border-bottom: thin ridge; font-family: Verdana; height: 211px;
background-color: #FFFFE8">
Convert:
<input type="text" id = "US" runat = "server"/>
U.S. dollars to Euros.
<br /><br />
<input type="submit" value="OK" id="Convert" runat = "server"
OnServerClick = "Convert_ServerClick"/>
<br /><br />
</div>
<div style = "font-weight:bold" id = "Result" runat = "server">
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Convert_ServerClick(object sender, EventArgs e)
{
decimal USAmount = Decimal.Parse(US.Value);
decimal euroAmount = USAmount * 0.85M;
Result.InnerText = USAmount.ToString() + "U.S. dollars = ";
Result.InnerText += euroAmount.ToString() + "Euros.";
}
}
}