Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an ajax calendar extender control where i need to calculate the future date..ie:-an Expiry date for users.If i select to days date in my text 1 it will be 7/12/2012 and in my text2 it should calculate for next 30 days and display it as 7/1/2013...Pls find me any soln...
Posted

Try this
C#
DateTime firsttext= Convert.ToDateTime("7/12/2012");

// add digit in textbox or add some validation 
DateTime answer = firsttext.AddDays(Convert.Todouble(TextBox2.Text));


Refer this
Adding Business Days to a Date
http://msdn.microsoft.com

or
If you want it done through javascript then call this function in second textbox onchange event
JavaScript
function aaddate()
{
var txt1 = document.getelementByID('<%# txt1.ClientID%');
var txt2 = document.getelementByID('<%# txt2.ClientID%');
var today = new Date(txt1.value);
var tomorrow = new Date();
tomorrow.setDate(today.getDate()+ parseInt(txt2.value));
}
 
Share this answer
 
v3
C#
string txt1 =  "7/12/2012";
DateTime dt = Convert.ToDateTime(txt1);
DateTime dt1 = dt.AddDays(30);
string txt2 = dt1.ToString("dd/MM/yyyy");

--SJ
 
Share this answer
 
Comments
kabifarm 25-Aug-15 5:44am    
Thanks this worked for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900