Search code examples
c#asp.netvisual-studio-2012ajaxcontroltoolkit

Ajax Calendar Extender tip NOT showing with a textbox


Despite downloading,installing and adding AjaxControlToolkit in VS2012(Ultimate) to my project, I am unable to access its "CalanderExtender" object feature.

.aspx file code is:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Documents.aspx.cs" Inherits="a.Documents" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit"%>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

Web.Config is:

<?xml version="1.0" encoding="utf-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
<pages><controls><add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /></controls></pages></system.web>

</configuration>

Now, what I don't understand is, despite adding AjaxControlToolkit into the project, adding ScriptManager from AJAX Extensions, adding and registering Assembly, CalanderExtender tip is not showing with the text box that I have added in the above code. When I try to manually add CalanderExtender using following code:

<asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="txtDate" TargetControlID="TextBox1" PopupPosition="Right"></asp:CalendarExtender>

It throws the following error in .aspx file:

Error Creating Control - CalendarExtender1
Unknown server tag 'asp:CalendarExtender'.

Irony of the fact is I have implemented this Ajax Calendar feature heaps of times before but never faced an issue as this one.

Please help.

Kind regards.


Solution

  • AjaxControlToolkit is registered both at the top of your page and in your web.config with the TagPrefix property ajaxToolkit, so you need to declare the CalendarExtender as:

    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="txtDate" TargetControlID="TextBox1" PopupPosition="Right"></ajaxToolkit:CalendarExtender>