Wednesday 6 February 2013

Celsius to Fahrenheit Converter in asp.net C#

Celsius to Fahrenheit Converter in asp.net C#


Add 2 textboxes with Auto Postback enabled and TextChange Event handler.


Conversion Formula:

C/5 = F-32/9


Celsius TextBox change Event handler.


   protected void txtCelsius_TextChanged(object sender, EventArgs e)
        {
            Decimal outputCelsius;
            Decimal.TryParse(txtCelsius.Text, out outputCelsius);
          
            txtFarenheit.Text = String.Format("{0:F2}", ((outputCelsius/5)*9)+32);
        }


Fareinheat TextBox Change Event handler.



  protected void txtFarenheit_TextChanged(object sender, EventArgs e)
        {
            //calendardemo / 5 = false - 32 / 9;
            Decimal outputFarein;
            Decimal.TryParse(txtFarenheit.Text, out outputFarein);
            txtCelsius.Text = String.Format("{0:F2}", (((outputFarein - 32) / 9) * 5));
        }


OUTPUT:

Fahrenheit to CelSIUS Converter in asp.net C# VB.NET
Tags:Celsius to Fahrenheit Converter in asp.net C#,Farenheit to Celsius converter in asp.net,Textbox Autopostback,Textbox Textchange event handler,

No comments:

Post a Comment