Professional Documents
Culture Documents
05 - Seminar - 1
05 - Seminar - 1
F = (C * 9) / 5 + 32;
C = (F – 32) * 5 / 9;
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="background-color:burlywood; position:center">
<form id="form1" runat="server" style="align-items:center; margin-left: 25%;
margin-top: 15%; ">
</form>
</body>
</html>
Kodi ne TemperatureConvertForm.aspx.cs
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 TemperatureConvertForm : System.Web.UI.Page
{
#region Public methods
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
FillConvertionType();
}
}
#endregion
#region Private methods
private void FillConvertionType()
{
// mbushet lista me radio button me vlera
TempRadioButtonList.Items.Add(new ListItem("Celcius", "1"));
TempRadioButtonList.Items.Add(new ListItem("Fahrenheit", "2"));
// elementi i pare checkohet
TempRadioButtonList.Items[0].Selected = true;
}
#endregion
if (TempRadioButtonList.SelectedValue == "1")
{
try
{
//Konvertohet nga celcus ne Fahrenheit
c = decimal.Parse(txtCelsious.Text);
//F = (C * 9) / 5 + 32;
f = (c * 9) / 5 + 32;
txtFahrenheit.Text = f.ToString();
txtCelsious.Style["Border-color"] = "black";
}
catch (Exception ex)
{
txtCelsious.Style["Border-color"] = "Red";
ResultLabel.Text = "Ju lutem rishikoni vleren e vendosur ne kutine
Celvius!";
}
}
}
if (TempRadioButtonList.SelectedValue == "2")
{
try {
//Konvertohet nga celcus ne Fahrenheit
f= decimal.Parse(txtFahrenheit.Text);
//C = (F – 32) * 5 / 9;
c = (f-32)*5/9;
txtCelsious.Text = c.ToString();
txtFahrenheit.Style["Border-color"] = "black";
}
catch (Exception ex)
{
txtFahrenheit.Style["Border-color"] = "Red";
ResultLabel.Text = "Ju lutem rishikoni vleren e vendosur ne
kutine Celvius!";
}