开发者

Calendar using Ajax toolkit

开发者 https://www.devze.com 2023-03-27 20:54 出处:网络
I\'m trying to implement a calendar in my ASP.NET web page using AJAX toolkit in JavaScript for creating dynamically textbox and populate it with popup calendar. The code is as follows:

I'm trying to implement a calendar in my ASP.NET web page using AJAX toolkit in JavaScript for creating dynamically textbox and populate it with popup calendar. The code is as follows:

for(var j=1; j<2;j++)
{
    <asp:ToolkitScriptManager runat="server"></asp:ToolkitScriptManager>
    <input type="text" ID="startDate"+j runat="server" BackColor="#D6E4ED" 
        BorderStyle="Inset" Width="10px" ></input>
    <asp:CalendarExtender runat="server" TargetControlID="startDate"+j> 

}

After viewing in browser its giving the following error:

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:

System.Web.HttpException: The control collection cannot be modified during DataBind, Init, Load, PreRender or    Unload phases.

Source Error:

An unhandled exception was generated 开发者_StackOverflowduring the execution of the current web request. 
Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.]

System.Web.UI.ControlCollection.Add(Control child) +8677431

AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in C:\Users\Stephen\Documents\Repos\Superexpert\AjaxControlToolkit\Server\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:323 AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in C:\Users\Stephen\Documents\Repos\Superexpert\AjaxControlToolkit\Server\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:305 System.Web.UI.Control.LoadRecursive() +50

System.Web.UI.Control.LoadRecursive() +141

System.Web.UI.Control.LoadRecursive() +141

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Please suggest something to solve the problem.


See if you are trying to write a code block in your masterpage head <% %>. This was the answer to my same problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号