<!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">
<script type="text/javascript">
function check() {
var temp = document.getElementById("txtfah");
if (temp.value == "" || temp.value == null) {
alert("Enter the Fahrenhiet");
temp.focus();
return false;
}
if(isNaN(temp.value))
{
alert("Please Enter The Numeric Only");
temp.focus();
return false;
}
return true;
}
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter The Fahrenhiet"></asp:Label>
<asp:TextBox ID="txtfah" runat="server" ontextchanged="txtfah_TextChanged"></asp:TextBox>
<asp:Button ID="Convert" runat="server" Text="Convert" OnClientClick="check()"
onclick="Convert_Click"/>
<asp:TextBox ID="txtresult" runat="server" ontextchanged="txtresult_TextChanged"
></asp:TextBox>
</div>
</form>
</body>
</html>
C# sharp Coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class temp : System.Web.UI.Page
{
int a;
float result;
protected void txtfah_TextChanged(object sender, EventArgs e)
{
a=int.Parse(txtfah.Text);
}
protected void Convert_Click(object sender, EventArgs e)
{
result = 5 * (a - 32) / 9;
Response.Write(result);
txtresult.Text = result.ToString();
}
protected void txtresult_TextChanged(object sender, EventArgs e)
{
}
}
No comments:
Post a Comment