使用 Ajax 工具包的日历
我正在尝试使用 JavaScript 中的 AJAX 工具包在 ASP.NET 网页中实现日历,以动态创建文本框并用弹出日历填充它。代码如下:
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>
}
在浏览器中查看后出现以下错误:
在DataBind、Init、Load期间不能修改控件集合, 预渲染或卸载阶段。描述:未处理的异常 发生在当前 Web 请求执行期间。请 查看堆栈跟踪以获取有关错误及其位置的更多信息 它起源于代码。
异常详细信息:
System.Web.HttpException: The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
源错误:
An unhandled exception was generated during 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.
堆栈跟踪:
[HttpException (0x80004005): 无法修改控件集合 在 DataBind、Init、Load、PreRender 或 Unload 阶段。]
System.Web.UI.ControlCollection.Add(控件子级)+8677431
AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(控制 控制)中 C:\Users\Stephen\Documents\Repos\Superexpert\AjaxControlToolkit\Server\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:323 AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) 中 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(布尔值 includeStagesBeforeAsyncPoint、布尔值 includeStagesAfterAsyncPoint) +627
请提出解决问题的建议。
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 during 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看您是否尝试在母版页头 <% %> 中编写代码块。这是我同样问题的答案。
See if you are trying to write a code block in your masterpage head <% %>. This was the answer to my same problem.