-
Notifications
You must be signed in to change notification settings - Fork 0
/
example Week 4.txt
58 lines (56 loc) · 2.1 KB
/
example Week 4.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _CurrencyConverter : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fromCurrencyDropDown.Items.Add(new ListItem("INR", "65.3"));
fromCurrencyDropDown.Items.Add(new ListItem("Japanese Yen", "110.33"));
fromCurrencyDropDown.Items.Add(new ListItem("Euro", "0.85"));
}
}
protected void SubmitClickedEvent(object sender, EventArgs e)
{
string convertedValue = convertCurrency();
labelAns.Text = convertedValue.ToString();
}
string convertCurrency()
{
double oldValue = 0;
double newValue = 0;
double.TryParse(inputCurrency.Text, out oldValue);
ListItem temp = fromCurrencyDropDown.Items[fromCurrencyDropDown.SelectedIndex];
newValue = oldValue * double.Parse(temp.Value);
string s = oldValue.ToString() + " USD = " + newValue.ToString() + " " + temp.Text;
return s;
}
}
-----------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CurrencyConverter.aspx.cs" Inherits="_CurrencyConverter" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" id="Label1" text="Input Currency"></asp:Label>
<asp:TextBox runat="server" id="inputCurrency"/></asp:textbox>
<asp:Label id="fromLable" runat="server" text="From USD to"></asp:Label>
<asp:DropDownList id="fromCurrencyDropDown" runat="server"></asp:DropDownList>
<br> <br>
<asp:Label runat="server" id="labelAns"></asp:Label>
<br> <br>
<asp:Button Text="Convert!" OnClick="SubmitClickedEvent" runat="server"></asp:Button>
<br><br>
</div>
</form>
</body>
</html>