我正在尝试从AJAXTool工具包中添加CalenderExternder功能。当我将控件添加到我的页面,构建和调试时,我收到以下错误:
无法修改Controls集合,因为控件包含代码块(即<%...%>)。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Web.HttpException:无法修改Controls集合,因为该控件包含代码块(即<%...%>)。
来源错误: 在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息 堆栈跟踪: [HttpException(0x80004005):无法修改Controls集合,因为控件包含代码块(即<%...%>)。] System.Web.UI.ControlCollection.Add(Control child)+9600379 AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(控件控件)+702 AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e)+62 System.Web.UI.Control.LoadRecursive()+54 System.Web.UI.Control.LoadRecursive()+ 145 System.Web.UI.Control.LoadRecursive()+ 145 System.Web.UI.Control.LoadRecursive()+ 145 System.Web.UI.Control.LoadRecursive()+ 145 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+772
这是我的整个页面代码,只要我的代码中没有标记,它就可以正常工作。我在我的web.config文件中注册了工具包,而且母版页正在使用ToolkitScriptManager
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminLayout.Master" AutoEventWireup="true" CodeBehind="ManageReleaseInfo.aspx.cs" Inherits="FFInfo.Staff.Sections.ManageReleaseInfo" %>
<asp:Content ID="phContent" ContentPlaceHolderID="phContent" runat="server">
<h2 class="text-center">
<asp:Literal ID="lblTitle" runat="server" />
</h2>
<asp:Label ID="lblResults" CssClass="text-error" runat="server" />
<asp:ValidationSummary ID="vsErrorSummary" CssClass="text-error" DisplayMode="BulletList" HeaderText="The following errors have been found:" runat="server" />
<p>
What section is this for?
<asp:DropDownList ID="ddlSectionList" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value="-1" Text="Select Section Title" />
</asp:DropDownList>
<br />Release Title:
<asp:TextBox ID="tbReleaseTitle" Columns="50" runat="server" />
<asp:RequiredFieldValidator ID="ReleaseTitleRequired" ControlToValidate="tbReleaseTitle" Display="Dynamic" CssClass="text-error" Text="*" ErrorMessage="Please there the release title." runat="server" />
<br />Platform:
<asp:DropDownList ID="ddlPlatform" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value="-1" Text="Select Platform" />
</asp:DropDownList>
<br />Publisher:
<asp:DropDownList ID="ddlPublisher" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value="-1" Text="Select Publisher" />
</asp:DropDownList>
<br />Release Location:
<asp:DropDownList ID="ddlLocation" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value="-1" Text="Select Locaiton" />
</asp:DropDownList>
<br />Estimated Release Date:
<asp:DropDownList ID="ddlReleaseDate" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value="-1" Text="Select Estimated Date" />
</asp:DropDownList>
<br />Exact Release Date:
<asp:TextBox ID="tbReleaseDate" AutoCompleteType="Disabled" runat="server" />
<asp:CalendarExtender ID="ceReleaseDate" TargetControlID="tbReleaseDate" runat="server" />
<asp:RegularExpressionValidator ID="ReleaseDateCheck" ControlToValidate="tbReleaseDate" ValidationExpression="^([0-9]{1,2})[./-]+([0-9]{1,2})[./-]+([0-9]{2}|[0-9]{4})$" Display="None" ErrorMessage="Please enter a valid date in MM/DD/YYYY format please." runat="server" />
</p>
</asp:Content>
答案 0 :(得分:4)
在准备晚餐并回来之后我又开始谷歌了,并在http://forums.asp.net/t/1172295.aspx/1发现了一个非常真实的帖子
在测试中,我在我的母版页上捆绑了引发问题的sytles。我只需要在我的标签中使用PlaceHolder标签擦除style.render标记。一旦完成,一切都很好。