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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramesh MaruthiPosted Jul 30, 2014, 1:00 PM
<%@ 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
});
}