Controls集合不能修改,因为该控件包含code块(即<%......%>)控件、为该、Controls、GT

2023-09-10 16:31:08 作者:赤脚踏两船

我坚持这个错误,发现周围的工作和解决方案,为我工作,但二想知道是不是解决问​​题的最佳方式,我想,以确保它不会影响任何其他页面严重。希望专家们会有所帮助。 如果这是最好的解决方案,那么很多的,你可以保存你的头。

在code块放置在母版出现此错误。请将code块在一个占位符来解决issue.When添加AJAX扩展到您的网页,它会尝试在头顶注册脚本。如果code块是present在母版,可能会发生错误。

要解决此问题,只需将code座到占位符在你的母版的头,像这样:

 <头ID =头像1=服务器>
    <冠军>无标题页< /标题>
    <链接的href =stylesheet.css中相对=样式类型=文本/ CSS/>
    < ASP:的ContentPlaceHolder ID =myPlaceholder=服务器>
    < SCRIPT LANGUAGE =JavaScript的类型=文/ JavaScript的SRC =<%= Page.ResolveClientURL(〜/ JavaScript的/ global.js)%>>< / SCRIPT>
    < / ASP:的ContentPlaceHolder>
    < ASP:的ContentPlaceHolder ID =头=服务器>< / ASP:的ContentPlaceHolder>
< /头>
 
excel 2007里面没有日历控件

解决方案

该错误是合乎逻辑的,你不能混淆呈现的控制,他们通过使用&LT渲染后;%=%>

要解决这个问题的一种方法是使用文字的控制,并呈现背后code中的脚本行。

 < ASP:的ContentPlaceHolder ID =myPlaceholder=服务器>
    < ASP:文字=服务器ID =txtIncludeScript的EnableViewState =假>< / ASP:文字>
< / ASP:的ContentPlaceHolder>
 

和背后code。检查是否为空,因为如果你改变了占位文字为空。另外设置的EnableViewState = false,因为你在每个Page_Load中设置它,你不希望将其保存到视图状态。

 如果(txtIncludeScript!= NULL)
  {
    txtIncludeScript.Text =
的String.Format(<脚本语言= \的JavaScript \型= \文/ JavaScript的\SRC = \{0} \>< / SCRIPT>中,
Page.ResolveClientUrl(〜/ JavaScript的/ global.js));
  }
 

I am stuck with this error and found a work around and the solutions works for me, but i i would like to know is it the best way to fix the issue and i want to make sure that it wont affect any other pages badly. Hope the experts will help. If this was the best solution then many of you can save your heads.

This error occurs when a code block is placed in the MasterPage. Place the code block in a placeholder to resolve the issue.When adding AJAX extenders to your Web page, it will attempt to register scripts in the head. If code blocks are present in the MasterPage, an error might occur.

To resolve this issue, simply move the code block into a placeholder in the head of your MasterPage, like so:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="myPlaceholder" runat="server">
    <script language="javascript" type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/global.js")%>"></script>
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>

解决方案

The error is logical you can not confuse the rendered controls after they rendered by using the <%= %>

One way to solve this issue is to use a literal control, and render the script line on code behind.

<asp:ContentPlaceHolder ID="myPlaceholder" runat="server">
    <asp:Literal runat="server" ID="txtIncludeScript" EnableViewState="false"></asp:Literal>
</asp:ContentPlaceHolder>

and on code behind. Check for null because if you change the placeholder the literal is null. Also set EnableViewState=false because you set it on every Page_Load and you do not wish to save it to viewstate.

  if(txtIncludeScript != null)
  {
    txtIncludeScript.Text = 
string.Format("<script language=\"javascript\" type=\"text/javascript\" src=\"{0}\"></script>",   
Page.ResolveClientUrl("~/javascript/global.js"));
  }