Wednesday, January 2, 2019

asp.net birth date


Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>  
 ENTER YOUR NAME nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server" Width="204px"></asp:TextBox>
        <br />
        ENTER YOUR BIRTHDATE&nbsp;
        <asp:TextBox ID="TextBox2" runat="server" Width="204px"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="CALCULATE" Width="245px" />
        <br />
        <br />
  
    </div>
    </form>
<p><%  Response.Write("hi " & un & "<br>")
       Response.Write("your birthdate is  " & bdt & "<br>")
       Response.Write("Todays  date  is " & cdt & "<br>")
       Response.Write("you have lived on this beautiful earth for precious " & dy & "  days")
       %></p>

</body>
</html>

Default.aspx.vb
Partial Class _Default
    Inherits System.Web.UI.Page
    Public un As String
    Public bdt As Date
    Public cdt As Date
    Public dy As Integer
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        un = Request.Form("TextBox1")
        bdt = Request.Form("TextBox2")
        cdt = Now()
        dy = DateDiff("D", bdt, cdt)
    End Sub
End Class



No comments:

Post a Comment