Wednesday, March 21, 2012

CalendarExtender show years

How show years on start?

Hi I met this problem flexebilty of ajax is not good ,

anyway you could do the next step(It might take some time for you)

1. Open ajax contrul toolkit solution.

2. in the javascript file

show :function() - is the first to be load - put an alert (show)

alert("show"); to see it actully arrived to there

3. same for function :switchMonth- alert("_switchMonth");

4.Do not try yet to see the alerts(please wait).

4.5 replace the this._mode ="years"; to this._mode ="days";

5. Build solution for all the project

6. Run the sample web site it should work - i tested it ,

7. now the dll in the bin directory should be uplad to your project

Hope it help you

ahh - remove the alerts

Tal gaviser

tgwiser@.gmail.com


Hi Metadont,

If you don't want to modify its source code, you can do it like this.

 <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" Format="yyyy-MM-dd" OnClientShown="onCalendarShown"> </ajaxToolkit:CalendarExtender> <script type="text/javascript" language="javascript"> function onCalendarShown(sender,args){ sender._switchMode("years", true);
 //sender._switchMode("months", true); } </script>

I hope this help.

Best regards,

Jonathan


Hi Jhomtan,

I am a little interested from your asnswer.

how the script methodonCalendarShown know to run when calander is ariae(delegate? where?)

what is the logic behind this solution

cheers

Tal g


Hi Talg,

CalendarExtender.cs

[DefaultValue("")]
[ExtenderControlEvent]
[ClientPropertyName("shown")]
public virtual string OnClientShown
{
get { return GetPropertyValue("OnClientShown", string.Empty); }
set { SetPropertyValue("OnClientShown", value); }
}

CalendarBehavior.js

add_shown : function(handler) {
/// <summary>
/// Adds an event handler for the <code>shown</code> event.
/// </summary>
/// <param name="handler" type="Function">
/// The handler to add to the event.
/// </param>
/// <returns />

this.get_events().addHandler("shown", handler);
}

For more, you should dip into the Extender's source code.

I hope this help.

Best regards,

Jonathan


Tnx,

I watch it, It seem to be more clear now

No comments:

Post a Comment