4 July 2012

CalendarExtender show only years asp.net ajax control

Calendar Extender show only years asp.net ajax control 
reference -> ajaxcontroltoolkit.dll

   < form id="form1" runat="server">
  < ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptGlobalization="true"
        EnableScriptLocalization="true" ID="ScriptManager1" ScriptMode="Debug" CombineScripts="false" />

<script type="text/javascript" language="javascript">
    function onCalendarShown() {
        var cal = $find("calendar1");
        cal._switchMode("years", true);
        if (cal._yearsBody) {
            for (var i = 0; i < cal._yearsBody.rows.length; i++) {
                var row = cal._yearsBody.rows[i];
                for (var j = 0; j < row.cells.length; j++) {
                    Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call);
                }
            }
        }
    }

    function onCalendarHidden() {
        var cal = $find("calendar1");
        if (cal._yearsBody) {
            for (var i = 0; i < cal._yearsBody.rows.length; i++) {
                var row = cal._yearsBody.rows[i];
                for (var j = 0; j < row.cells.length; j++) {
                    Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", call);
                }
            }
        }
    }

    function call(eventElement) {
        var target = eventElement.target;
        switch (target.mode) {
            case "year":
                var cal = $find("calendar1");
                cal.set_selectedDate(target.date);
                cal._blur.post(true);
                cal.raiseDateSelectionChanged(); break;
        }
    }
</script>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" OnClientHidden="onCalendarHidden"  
 OnClientShown="onCalendarShown" Format="yyyy" BehaviorID="calendar1"  TargetControlID="TextBox1">
</ajaxToolkit:CalendarExtender>
</div>
</form>

No comments:

Post a Comment

Comments Welcome

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...