views:

399

answers:

2

Hey,

I'm trying to use Ajax Toolkit in ASP.NET page to display a Calendar Extender with this code, but it's not working for me.

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<br />
<br />
<b>Calendar :</b><br />
    <asp:TextBox ID="Date1" runat="server"></asp:TextBox>
    <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Date1">
    </asp:CalendarExtender>
</div>
</form>

It's not displaying the calendar.

What's the problem ?

+1  A: 

Try:

<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Date1">
</ajaxToolkit:CalendarExtender>

Update:

Do you have the following in your web.config?

    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="asp" />
      </controls>
    </pages>

    <compilation>
        <assemblies>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </assemblies>
    </compilation>

    <httpHandlers>
        <remove verb="*" path="*.asmx" />
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>

    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>

Update II

Put the following at the top of your aspx page.

<%@ Register Tagprefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>

Also, you're referencing AjaxControlToolkit.dll, right? It should be in your bin directory. Right-click project, Add Reference menu choice to add.

Steve
`<ajaxToolkit:CalendarExtender` It's not working for me. I have just <asp: ...
dotNET
Added web.config contents. Do you have the above web.config lines?
Steve
I putted those lines, but in the design tab I have this error message :Unable to display this control because its TagPrefix is not registered in this form.
dotNET
Did you put in both register directives? Phil's is for the calendar, mine is for the toolkit. Did you undo the <ajaxToolkit:CalendarExtender changes back to <asp:CalendarExtender?
Steve
A: 

Have you added a Register directive to your page for the CalendarExtender?

<%@ Register TagPrefix="asp" TagName="CalendarExtender" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>

(Or added it in web.config like Steve suggested)

Have you added an assembly reference to the AjaxControlToolkit dll?

PhilPursglove
I putted those lines, but in the design tab I have this error message : Unable to display this control because its TagPrefix is not registered in this form.
dotNET