Вопрос

I have a DetailsView with a bunch of EditItemTemplates. One of them has a text box that accepts dates. In order to make the form more user friendly I wanted to add an Ajax toolkit calendar control so the user can pick a date from the calendar. I keep getting an error when trying to load the page.

Parser Error Message: Unknown server tag 'ajc:Calendar'.

My register tag is correct.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajc" %>

My EditItemTemplate looks like this. Nothing fancy.

 <EditItemTemplate>
       <asp:TextBox ID="txtGrantedDate" runat="server" Text='<%#  Bind("GrantedDate") %>' />
       <ajc:Calendar  PopupPosition="Right" runat="server"
              TargetControlID="txtGrantedDate"
              Format="MMMM d, yyyy" SelectionMode="Day"
              PopupButtonID="imgGrantedDate" ></ajc:Calendar>
       <asp:Image ID="imgGrantedDate" runat="server" Width="20px" Height="20px" AlternateText="calendar" ImageUrl="~/Images/calendar.png" />
 </EditItemTemplate>

Where might I be going wrong and are ajax controls even allowed in DetailsView controls?

Это было полезно?

Решение

Well this was silly. In case you guys run into this issue the correct server tag for the calendar extender is

<ajc:CalendarExtender> 

Not

<ajc:Calendar>

The reason for the confusion you ask? Well it turns out that the samples on the Ajax control toolkit contains the following:

<ajaxToolkit:Calendar runat="server"
    TargetControlID="Date1"
    CssClass="ClassName"
    Format="MMMM d, yyyy"
    PopupButtonID="Image1" />

You can take a look at it for yourself at:

Ajax Control Toolkit Calendar Extender

Expand the Calendar Properties section and you'll see the code I copied above.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top