Hi
How to Count your age after that age display in Lablel contol ?
I need Any example ...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jul 30, 2014, 9:00 AM EDT
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="age.aspx.cs" Inherits="countage.age" %>
Aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace countage
{
public partial class age : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Selection_changed(object source, EventArgs args)
{
if(Calendar1.SelectedDate != null)
{
int dob = Calendar1.SelectedDate.Year;
int today = DateTime.Now.Year;
string age = (today -dob).ToString();
Label1.Text = string.Format("the age is {0}", age);
}
}
}
}
By using javscript u can do in this way
using Javascript:
function{
$('#dob').datepicker({
onSelect: function(value, ui) {
var today = new Date(),
dob = new Date(value),
age = new Date(today - dob).getFullYear() - 1970;
$('#age').text(age);
},
maxDate: '+0d',
yearRange: '1920:2014',
changeMonth: true,
changeYear: true
});
}