-4

Possible Duplicate:
How to add or subtract dates in C# using ajax calendar extender?

I have two textboxes in which i have used ajax calendar extender. When I choose a date from one textbox, I want the other one filled with a date calculated from the one selected by adding some days or months. How can i do that?

Community
  • 1
  • 1
Umair Javed
  • 1
  • 1
  • 4
  • 5
    You must not duplicate your questions: here you ask for something and wait for others to reply! If you are in a hurry, call someone and pay for this!! Anyway, you're new here, so you should learn. Welcome to StackOverflow! – Marco Oct 22 '12 at 07:25
  • 1
    ok sorry next time i will follow the rules and regulation. – Umair Javed Oct 22 '12 at 07:26

2 Answers2

0

try this

DateTime? SelDate = myCalendarExtender.SelectedDate;

if (SelDate != null)
{
    DateTime SelectedDate = SelDate .Value;
}

DateTime Selected_Date= SelectedDate ;

DateTime result= Selected_Date.AddDays(30);
Karthik
  • 2,391
  • 6
  • 34
  • 65
0

I assume you want the date on the second TextBox to change after the user has selected a calendar date on the first TextBox. You need to intercept the OnClientDateSelectionChanged event (on the client) (in javascript) and write a handler (in javascript) that will update the value on the second TextBox from the value selected on the first

Basically given this:

<asp:TextBox ID="tbFirst" runat="server"></asp:TextBox>
<asp:TextBox ID="tbSecond" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender7" 
runat="server" OnClientDateSelectionChanged="DateSelected" TargetControlID="tbFirst" />

Then in a javascript block you:

function DateSelected(sender,args)
{
     alert('You have selected : ' + sender._selectedDate);
     //TODO: Select the second box and set it's value to whatever is needed 

}
Mong Zhu
  • 23,309
  • 10
  • 44
  • 76
Radu094
  • 28,068
  • 16
  • 63
  • 80