Tuesday, August 19, 2008 1:53 PM rrobbins

How To Add A New Property To The AJAX Calendar Control

I've finally gotten around to using something from the AJAX Control Toolkit in an actual project. My client was dissatisfied with the <asp:calendar> control so I offered to AJAX enable the site and replace it with the fancier Calendar control from the ASP.NET AJAX Control Toolkit. Naturally the client found something he wanted to work a little different. This calendar control was for entering your birth date and he did not want the user to scroll back decades to find that date. He wanted the calendar to show up with the 1990-1999 decade already visible so the user could start from there. Fortunately I remembered that the ASP.NET AJAX Control Toolkit comes with all the source code so you can customize it to suite your needs.

This requirement was extremely easy to implement. All you really need to do is set the calendar mode to "years" when you first show it. However there was no property for initial mode so I had to create one. This was virtually a cut and paste hack because there are existing properties to base it on.

1. Open CalendarExtender.cs and create a new ExtenderControlProperty:

   1: [DefaultValue("")]
   2: [ExtenderControlProperty]
   3: [ClientPropertyName("initialMode")]
   4: public virtual string InitialMode
   5: {
   6:    get { return GetPropertyValue("InitialMode", string.Empty); }
   7:    set { SetPropertyValue("InitialMode", value); }
   8: }

2. Open CalendarBehavior.js and create a new member:

   1: this._initialMode = null;

3. Also in CalendarBehavior.js add new get and set functions for the property access:

   1: get_initialMode : function() { 
   2:     /// <value type="String">
   3:     /// The initial mode of the calendar
   4:     /// </value>
   5:  
   6:     return this._initialMode; 
   7: },
   8: set_initialMode : function(value) { 
   9:     if (this._initialMode != value) {
  10:         this._initialMode = value; 
  11:         this.raisePropertyChanged("initialMode");
  12:     }
  13: }, 

4. And finally set the _switchMode in the show : function() with this new line of code:

   1: this._switchMode(this._initialMode, true);

Compile the AjaxControlToolkit project and copy the AjaxControlToolkit.dll file to your bin directory. Now you can use your new property in the Calendar control like so:

   1: <ajaxToolkit:CalendarExtender ID="calendarButtonExtender" runat="server" TargetControlID="Date5" 
   2:             PopupButtonID="Image1" InitialMode="years" />
Calendar-Years-Mode[4] Filed under: ,

Comments

# re: How To Add A New Property To The AJAX Calendar Control

Monday, November 17, 2008 2:06 PM by kk18_b

can you please tell me whether we can any property where it just displays the months instead of dates. I mean, I dont want to display the dates in my ajax calendar control.

# re: How To Add A New Property To The AJAX Calendar Control

Monday, March 02, 2009 11:54 PM by HsvsRsvsesv

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, December 23, 2010 4:21 AM by Joan Doyle

fail???

My Regards

<a href="http://alternativemedicine.org.in">alternative medicine course</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, December 23, 2010 10:31 PM by Isabelle Cote

Hey , lol =D

Best regards

<a href="alternativemedicinecourse.com/.../naturopathy-courses">naturopathy courses in India</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, December 24, 2010 9:28 PM by Tristan

I have to hear exactly what  thinks about that.

-Warm regards

<a href="http://www.SecurityCubed.com">security systems for home</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, December 25, 2010 4:45 AM by Dee

I am very pleased you said this post!!

<a href="http://www.findgroomers.com">dog grooming</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, December 25, 2010 10:46 PM by Morgan

Hey , lol?!?

<a href="http://alternativemedicine.org.in">alternative medicine college</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, December 26, 2010 6:27 PM by Cornelius Vang

ftw??

<a href="www.live-girls-webcam-chat.com/">chat dresden</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, December 27, 2010 8:37 PM by Natasha

Could be the most influential thing that I have read all month..

<a href="www.netezines.net/secrets-of-successful-traders-review">secrets of successful traders review</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, December 28, 2010 9:01 PM by Rae

rocks!

<a href="www.cigars-now.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, December 29, 2010 5:56 PM by Reyna Cline

Great post, been after that?!?

<a href="www.live-couples-webcam-chat.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, December 30, 2010 8:21 AM by Jarvis Carson

, whatever dude!!

<a href="http://webreputationmanagement.info">Click Here To View My Site</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, December 30, 2010 7:17 PM by Coleen

, WTF???

<a href="http://www.SecurityCubed.com">alarm systems for the home</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, December 31, 2010 7:43 PM by Reba

Great post! You might want to follow up on this topic :D

<a href="www.cigars-now.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, January 01, 2011 5:47 PM by Randolph Quigley

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, January 02, 2011 7:03 PM by Abdul

I am curious  what Rachael thinks about this?

<a href="www.netezines.net/joseph-matthews-the-art-of-approaching-review">the art of approaching</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, January 03, 2011 10:20 AM by Anna Lanier

Rosemary is the greatest!!!

<a href="http://www.findgroomers.com">dog grooming</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, January 04, 2011 7:39 PM by Guadalupe Kowalski

Zane ROCKS?

Max

<a href="www.cigars-now.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, January 05, 2011 9:10 PM by Iris

Herschel, I don't think so!

<a href="www.erotiklobby.com/">geli harry fototausch</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, January 06, 2011 9:54 PM by Virginia Dawson

Possibly the top paper that I have read all week..

<a href="alternativemedicine.org.in/acupressure.html">acupressure courses in India</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, January 08, 2011 9:35 PM by Brain Dillon

Hey Gilberto, WTF!

<a href="alternativemedicine.org.in/acupressure.html">acupressure courses</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, January 09, 2011 3:44 PM by Sonia

Possibly the best read that I read all month??

-My regards

Patsy

<a href="fickmaschine-live.com/">live fickmaschine</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, January 10, 2011 7:48 PM by Yvonne Do

This is the top page that I have read all year!?!

Kindest Regards

Jessie

<a href="www.ipcounter.net/">html counter code</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, January 11, 2011 10:13 PM by Rosanna Stubbs

I have to hear  what Juliana will change about that!!

-Sincerest Regards,

Alfreda

<a href="http://webreputationmanagement.info">corporate reputation management</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, January 13, 2011 12:39 AM by Larry

Dewayne, wtf!?!

<a href="www.netezines.net/boilx-review">boilx review</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, January 13, 2011 10:33 PM by Genevieve Burgess

Bridgette, yea right?!?

Fondest Regards

Hal

<a href="http://www.cigars-now.com">cigar</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, January 15, 2011 12:01 AM by Lynne

I am glad you said that!!

Warm Regards,

Shirley

<a href="www.cigars-now.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, January 15, 2011 10:33 PM by Carmen Sandoval

I am wondering exactly what Rae will change about this..

<a href="www.oregonlngpropertysearch.com/">moncler jacket</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, January 17, 2011 11:17 PM by Andrea Ly

Great blog post, I've been looking for that :)

<a href="http://www.asparagus-soap.com">Natural Soap</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, January 18, 2011 3:36 PM by Bobbi

I'm glad you said that!!!

<a href="www.parketarstvo-cerkvenik.si/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, January 20, 2011 3:48 AM by Angeline Mcgrath

Rhea rocks!?!

<a href="ezinearticles.com berry diet pills</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, January 21, 2011 1:34 AM by Elsie Cuevas

Isabelle is the best?!

Homer

<a href="http://www.gume-oblak.si">gume</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, January 22, 2011 5:58 AM by Milagros Mccoy

Alex, whatever man!

<a href="http://alternativemedicinecourse.com">alternative medicine</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, January 23, 2011 1:45 AM by Jennifer Torres

I need to know just what Tanner has to say about this :D

Eldon

<a href="www.gbbilder4you.com/">kostenlose gb bilder für jappy</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, January 24, 2011 3:52 AM by Johnnie

I'm very glad that you said that post!

Brittany

<a href="www.gbbilder4you.com/">lustig gb pics</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, January 24, 2011 11:23 PM by Susan

Great read! You may want to follow up to this topic!?

<a href="http://webreputationmanagement.info">brand reputation management</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, January 25, 2011 11:59 PM by Grace Vaughan

Great writing! I wish you could follow up to this topic?

<a href="mizarstvo-jereb.si/.../">previjalna miza</a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, January 26, 2011 9:42 PM by Susana Tobin

I'm happy that you said this post??

<a href="www.nacht-creme.net/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, January 27, 2011 11:57 PM by Erich Dietz

This is the BEST blog I have read in my life :D

<a href="www.oregonlngpropertysearch.com/">moncler jacket</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, January 30, 2011 11:26 PM by Garrett

This is the GREATEST page that I read this week!!!

-Yours truly

Casandra

<a href="http://www.cigars-now.com">cigars</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, February 01, 2011 2:50 AM by Mohamed

Great writing! Maybe you could do a follow up to this topic!!

<a href="www.cigars-now.com/.../a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, February 02, 2011 4:35 AM by Jess Padilla

I'm very thrilled you said that?!?

<a href="www.lida-schlankheitskapseln.com/">lida di�tpillen</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, February 04, 2011 12:46 AM by Antone

Kitty rocks :P

<a href="www.butikonlinemurah.com/">Butik Online Murah</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, February 04, 2011 11:29 PM by Edwin Frye

Clara ROCKS...

Noreen

<a href="http://www.findgroomers.com">dog grooming</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, February 05, 2011 9:12 PM by Scot

Marcelo is the greatest?!?

<a href="www.sumobulldogs.com/">AKC champion English bulldog stud service</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, February 06, 2011 11:58 AM by Ed Watson

Great post! You should definitely follow up to this topic!!

<a href="www.camchatladies.com/">rtl chat</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, February 08, 2011 9:22 PM by Henrietta Mathews

Great blog post, I have been after that!?

<a href="www.asparagus-soap.com/.../scrubs.html">Oatmeal scrubs</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, February 10, 2011 11:32 PM by Lou

The best blog that I read all week!!

Barney

<a href="www.butikonlinemurah.com/">Butik Online Murah</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, February 11, 2011 9:15 PM by Barney

I am glad you said that?!?

<a href="www.netezines.net/penny-stock-prophet-review">penny stock prophet review</a>

# re: How To Add A New Property To The AJAX Calendar Control

Monday, February 14, 2011 1:30 AM by Carmine Mcwilliams

Great post! Maybe you could do a follow up on this topic...

<a href="www.oregonlngpropertysearch.com/">moncler jacket</a>

# re: How To Add A New Property To The AJAX Calendar Control

Tuesday, February 15, 2011 5:49 AM by Leland Benjamin

I'm glad you said that...

Pedro

<a href="www.oregonlngpropertysearch.com/">moncler jackets</a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, February 16, 2011 1:53 AM by Antoinette

Orlando, yea right!?!

-Kind Regards

Newton

<a href="www.mystogie.com/.../gurkha-cigars.html">gurkha cigars</a>

# re: How To Add A New Property To The AJAX Calendar Control

Wednesday, February 16, 2011 11:35 PM by Maritza Koch

I have to hear just what Bob can do with that??

Gene

<a href="www.was-frauen-wollen.com/">schlechtes sperma</a>

# re: How To Add A New Property To The AJAX Calendar Control

Thursday, February 17, 2011 10:32 AM by Rusty

I have to hear exactly what Morton has to say about that!

<a href="http://www.zlatorogi.si">ansambel</a>

# re: How To Add A New Property To The AJAX Calendar Control

Friday, February 18, 2011 3:48 AM by Chris Elder

Heather is the greatest :P

<a href="http://popcornshows.com">streaming</a>

# re: How To Add A New Property To The AJAX Calendar Control

Saturday, February 19, 2011 2:21 AM by Ofelia

Letha FAIL =D

Kind regards,

Karl

<a href="http://www.latest-tv.com">streaming movies</a>

# re: How To Add A New Property To The AJAX Calendar Control

Sunday, February 20, 2011 12:33 AM by Bryan

Great post, been looking for that!!

Angelia

<a href="freiepotenzmittel.com/">rezept medikamente kaufen</a>

# Fickmaschine iris | Brooza

Monday, July 25, 2011 7:28 PM by Fickmaschine iris | Brooza

Pingback from  Fickmaschine iris | Brooza

# re: How To Add A New Property To The AJAX Calendar Control

Friday, April 20, 2012 5:06 AM by TheronAI

Cheap Celine supplied in best quality. All latest style Celine bag discount on sale on line. Welcome to shopping discount celine handbags back home from Our Celinie UK Store.

Leave a Comment

(required) 
(required) 
(optional)
(required)