Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I need to add an ajax calender extender in my aspx page.I added the dll & the tagprefix in the webconfig.

Add the refrence of dll to the apx page
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

I add the calenderextender as
XML
<asp:TextBox ID="txtDOB" runat="server"></asp:TextBox><asp:Label ID="lblErrFromdate" runat="server" Text="Er" ForeColor="Red"></asp:Label>
                                            <ajaxToolkit:CalendarExtender runat="server" ID="CldFromDate" TargetControlID="txtDOB"  Format="dd/MM/yyyy" PopupButtonID="imgCalendar1" ></ajaxToolkit:CalendarExtender>



But while i run the application i am getting the error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
VB
[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +9855103
   AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in C:\Program Files\Microsoft ASP.NET\asp.net 2.0 comp\AjaxControlToolkit 2.0 complaient\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:295
   AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in C:\Program Files\Microsoft ASP.NET\asp.net 2.0 comp\AjaxControlToolkit 2.0 complaient\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:307
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Control.LoadRecursive() +145
   System.Web.UI.Control.LoadRecursive() +145
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Posted

1 solution

Are you having any server side code in head tag if yes please move it to the body section.

Remove the part which has server tags and place it somewhere else if you want to add dynamic controls from code behind.
 
Share this answer
 
Comments
Member 11658469 22-Oct-15 3:34am    
There is no server side code in the head tag.Just some javascript functions.
[no name] 22-Oct-15 3:35am    
try to move your javascript to body tag or in the end of the page.
Member 11658469 22-Oct-15 3:46am    
That part also i tried but its not working..
Member 11658469 22-Oct-15 4:55am    
Its resolved thanks for the reply..
[no name] 22-Oct-15 3:48am    
Will you please post your code so that we can try to diagnose and resolve

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900