age_calculator.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="age_calculator.aspx.cs" Inherits="our_program.age_calculator" %>
<!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">
<title>Age calculator using calander control</title>
<center><h1>Age calculator using calander control</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Submit" onclick="btn_Click"></asp:Button>
<br />
<br />
<asp:Label ID="lbl" runat="server" Text="your age is calculated here "></asp:Label>
</div>
</center>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="age_calculator.aspx.cs" Inherits="our_program.age_calculator" %>
<!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">
<title>Age calculator using calander control</title>
<center><h1>Age calculator using calander control</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Submit" onclick="btn_Click"></asp:Button>
<br />
<br />
<asp:Label ID="lbl" runat="server" Text="your age is calculated here "></asp:Label>
</div>
</center>
</form>
</body>
</html>
age_calculator.asp.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class age_calculator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
DateTime data = Calendar1.SelectedDate;
String age = data.ToString("dd/MM/yyyy");
int ages = Convert.ToInt32(((DateTime.Now-data).TotalDays/365));
lbl.Text ="selected date is :"+ age +" and your age is :" +ages.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class age_calculator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
DateTime data = Calendar1.SelectedDate;
String age = data.ToString("dd/MM/yyyy");
int ages = Convert.ToInt32(((DateTime.Now-data).TotalDays/365));
lbl.Text ="selected date is :"+ age +" and your age is :" +ages.ToString();
}
}
}
No comments:
Post a Comment