Ajax Toolkit CalendarExtender (VB.NET)

Hi experts,

I am using the Ajax Toolkit CalendarExtender on a form. I have three textbox controls (txt1stday, txtlastday and txtrtnday), each using it's own CalendarExtender control. Each CalendarExtender defaults to the current month.

I need to know how to do 2 things:

1. When a user selects a date in a different month (and/or year) to the current month in the first calendar, I want the second and third calendar to automatically change the month (and/or year) to match the month of the first calendar.

2. The Format property exists for the CalendarExtender control. But I cannot seem to change the format to be user-friendly. It defaults to dd/MM/yyy. I would like to display the date as: Thursday 28 May 2009 instead of 28/05/2009.

Any help would be appreciated.

Thanks

Jon
LVL 11
Jon WinterburnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David RobitailleAnalyst ProgrammerCommented:

for 1 you have to change the SelectedDate of the others calendars (I think you need to postback to do this)

for 2 set the format to "Format="d MMMM  yyyy"

0
Jon WinterburnAuthor Commented:
The format thing is perfect - I just had to adjust it a bit to: dddd d MMMM yyyy - in order to get the day as well as the date. But thanks, that's brilliant - I should have tried 4 M's but didn't think of it!

I'll have a go at SelectedDate in the postback and come back to you.
0
David RobitailleAnalyst ProgrammerCommented:
Have you find how to postback? ex: you could set the target control to autopostback and then do your stuff in the text changed...
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Jon WinterburnAuthor Commented:
I have done some playing. I had to set:

CalendarExtender1.SelectedDate = DateTime.Now

...so that it populates the textbox, else it would not do anything. On clicking the calendar picker and changing the date, it postbacks CalendarExtender2 and then fills the second textbox with the same date as the first. Okay, but not ideal. Ideally I want all 3 textboxes blank to start with, CalendarExtender1 calendar to default to today (it does already) and when the date is picked, form postbacks and changes CalendarExtender2 to the right month and same date as CalendarExtender1 - but not populate textbox2 with said date.

Does that make sense? In the aspx page I added a property to CalendarExtender1:

OnClientDateSelectionChanged="function ddd(){__doPostBack('CalendarExtender2','') ;}"

...and in the code behind I added the attached:

If Page.IsPostBack Then
   CalendarExtender2.SelectedDate = CalendarExtender1.SelectedDate
       ElseIf Not Page.IsPostBack Then
          CalendarExtender1.SelectedDate = DateTime.Now
End If

Open in new window

0
David RobitailleAnalyst ProgrammerCommented:
Well, i would then suggest to switch away form the Ajax calendar extender an use a modalpopup extender or a popup extender with a standard asp:calendar in it.

I found modal pupup easier to use that the pupup, but the call is your.

With the standard Calandar, you could set a "visible date" diiferent from the "selected date".




0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David RobitailleAnalyst ProgrammerCommented:
i jsut saw that the popup exemple use a asp:calandar...

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/PopupControl/PopupControl.aspx
0
Jon WinterburnAuthor Commented:
Well, I'll go down that avenue if I have to. If I leave it as it is (with the dates populating the fields), I have only one problem. With my code as mentioned above, if I change the date of the first calendar, it momentarily changes before changing both itself and calendar2 to the current date! Even though I stated:

ElseIf Not Page.IsPostBack Then
          CalendarExtender1.SelectedDate = DateTime.Now
0
David RobitailleAnalyst ProgrammerCommented:
in witch function you put your code?
I would do it that way.
Page load :
If Not Page.IsPostBack Then
          CalendarExtender1.SelectedDate = DateTime.Now
End If
on the CalendarExtender1<s target text changed:
CalendarExtender2.SelectedDate =  CalendarExtender1.SelectedDate
 
 
0
Jon WinterburnAuthor Commented:
Yup, that's exactly what I'm doing. So close to getting this working!
0
David RobitailleAnalyst ProgrammerCommented:
you must be doing something else then, did you pui a breakpoint in the page load to make sure the code is not executed?
0
Jon WinterburnAuthor Commented:
This is madness. No matter where I add breaks, it makes no difference and just does the same thing.
0
David RobitailleAnalyst ProgrammerCommented:
?
adding break should help you to see whant hapenning... does the code getting executed as expected? you should be able to see where the CalendarExtender2`s value is changing back to now...
0
Jon WinterburnAuthor Commented:
After reading up on this I have realised that changing the calendar itself, and not the textbox is not possible with this calendar. I will scrap it and start again with a different control. Thanks for your efforts.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.