Home > Forum > ASP.NET > Need to show the date in asp.net

Need to show the date in asp.net

by Thamil   on Oct 12, 2014   Category: ASP.NET  |  Views: 1296    |  Points: 5   |  Gold 

In textbox1 i enter the value as 3 .in textbox2 i show the system date and i need to show the after 3 days date in textbox3

example: textbox1 3

textbox2 01/10/2014

textbox3 03/10/2014

i need to show the 03/10/2014 automatically in asp.net

Question postd on behalf of selvi

Bookmark and Share:
  User Reply  | Ask a question  |   Reply 
  Re :Need to show the date in asp.net   
by Thamil
on Oct 12 2014 6:53AM
Points : 10
Hi Selvi,

Please find the below sample code as per your requirement
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="date.aspx.cs" Inherits="LearnDev.date" %>
<!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>Date operations</title>
<script type="text/javascript" language="javascript">

function DateChange()
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var today = dd+'/'+mm+'/'+yyyy;
document.getElementById("<%=TextBox2.ClientID%>").value = today;
today = yyyy+'/'+mm+'/'+dd;
var myDate = new Date(today);
var num = document.getElementById('<%=TextBox1.ClientID%>').value;

var dt = new Date(myDate.getTime() + num*24*60*60*1000);
var newdd = dt.getDate();
var newmm = dt.getMonth()+1;
var newyy = dt.getFullYear();
var addedDt = newdd+'/'+newmm+'/'+newyy;

document.getElementById("<%=TextBox3.ClientID%>").value = addedDt;
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" onblur="DateChange()" runat="server"></asp:TextBox><br /><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br /><br />

Recent Post

Latest Posts