Ajax Toolkit ASP.NET (Visual Basic) Not Displaying Calendar

萝らか妹 提交于 2019-12-13 01:53:52

问题


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:


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.




回答2:


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?




回答3:


Well it is caused by ScriptManager. I have this same issue. The solution is very simple just delete ScriptManager From page or where you placed i.e.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

Once you delete scriptmanager then just place ToolkitscriptManager or below code:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>

You can find this in toolbar -> ajax tab not in Ajax Extensions tab. I hope it will solve your issue



来源:https://stackoverflow.com/questions/2943537/ajax-toolkit-asp-net-visual-basic-not-displaying-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!