Age Calculator using ASP.NET & C#

Category > ASP.NET || Published on : Friday, February 19, 2016 || Views: 12430 || Age Calculator using ASP.NET & C#


Here Pawan Kumar will explain how to Age Calculator using ASP.NET & C#


In previous post I have explained How to Create Tab Control Using jQuery In Asp.Net, jQuery Datepicker Calendar With Slide Down Effect In Asp.Net, jQuery Code To Select Multiple Item By Pressing Ctrl Button In Asp.Net, How to bind dropdown list with XML file in, Validate ASP.Net form using CSS in C#, API Demonstration ASP.NET, and many more articles.

Now I will explain How to Age Calculator using ASP.NET & C#

So follow the steps to learn Age Calculator using ASP.NET & C#

ASPX Code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            Age Calculator using ASP.NET & C#</h1>
        <asp:Label ID="lblAge" runat="server" Font-Bold="True" Font-Size="Larger"></asp:Label>

Code Behind:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        DateTime birthday = new DateTime(1981, 06, 15);

        DateTime today = DateTime.Today;
        int age = today.Year - birthday.Year;
        if (birthday > today.AddYears(-age))
            lblAge.Text = age.ToString(); ;

Output Screenshot:-


So, In this tutorial we have learned, Age Calculator using ASP.NET & C#

Download Source Codes