“无法修改控件集合,因为控件包含代码块”我试图创建一个简单的用户控件,这是一个滑块。当我向用户控件添加AjaxToolkit SliderExtender时,我得到以下内容(*&$#()@#Error): Server Error in '/' Application. The Controls collection cannot be modified because the control contains code blocks (i.e. ``). 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 Controls collection cannot be modified because the control contains code blocks (i.e. ``).
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 Controls collection cannot be modified because the control contains code blocks (i.e. ``).] System.Web.UI.ControlCollection.Add(Control child) +8677431 AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:293 AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:306 System.Web.UI.Control.LoadRecursive()
+50 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Control.LoadRecursive()
+141 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074我已经尝试在用户控件中放置一个占位符,并以编程的方式将TextBox和滑块扩展器添加到占位符中,我仍然会得到错误。有什么问题吗?
3 回答

湖上湖
TA贡献2003条经验 获得超2个赞
<head id="head1" runat="server"> <title>My Page</title> <link href="css/common.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<%# ResolveUrl("~/javascript/leesUtils.js") %>"></script></head>
<%# ... %>
protected void Page_Load(object sender, EventArgs e){ Page.Header.DataBind(); }

叮当猫咪
TA贡献1776条经验 获得超12个赞
<div runat="server"> //div tag must have runat server //Your Jave script code goes here....</div>
- 3 回答
- 0 关注
- 401 浏览
添加回答
举报
0/150
提交
取消