[CLOSED] ScriptManager throw exception in my masterpage

  1. #1

    [CLOSED] ScriptManager throw exception in my masterpage

    the exception is below:

    [CODE]

    <h2>The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). </h2>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:


    <table bgcolor="#ffffcc" width="100%">
    <tbody>
    <tr>
    <td><code>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.</code> </td></tr></tbody></table>
    Stack Trace:


    <table bgcolor="#ffffcc" width="100%">
    <tbody>
    <tr>
    <td><code></code>[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
    System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +8668018
    Coolite.Ext.Web.ScriptManager.AddItem(String key, String value, Boolean addToStart) +156
    Coolite.Ext.Web.ScriptManager.Page_PreRenderComple te(Object sender, EventArgs e) +118
    System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8698462
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029
    </td></tr></tbody></table>



    </p>



    </p><hr color="silver" size="1" width="100%">



    </p>


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
    </p>

    [/code</p>

    ]the masterpage sourcecode is below:
        <%@ Master Language="C#" AutoEventWireup="true" Codebehind="Site.master.cs" Inherits="ETMS.Web.Site" %>
    <%@ Register Src="ACUserControls/MainMenu.ascx" TagName="MainMenu" TagPrefix="uc1" %>
    <%@ Register Src="ACUserControls/SystemBulletin.ascx" TagName="SystemBulletin" TagPrefix="uc2" %>
    <%@ Register Src="ACUserControls/SMS.ascx" TagName="SMS" TagPrefix="uc3" %>
    <%@ Register Src="ACUserControls/BriefCase.ascx" TagName="BriefCase" TagPrefix="uc4" %>
    <%@ Register Src="ACUserControls/Information.ascx" TagName="Information" TagPrefix="uc5" %>
        <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <html>
    <head runat="server">
        <title>??????</title>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></p>
    
    
        <script language="javascript" type="text/javascript">
            //Add By Richard Zhang 2009-01-07
            //javascript ????
            
            //?????
            var ETMS_APP_PATH = "<%=ETMS_APP_PATH %>";
            
            
            //??LeftMenu??????
            function SwitchLeftMenu()
            {
                var div_spliter = &#100;ocument.getElementById("divSpliter");
                var div_left  = &#100;ocument.getElementById("divLeft");
                
                if (div_spliter.state == "on")
                {
                    div_left.style.display = "none";
                    div_spliter.state = "off"
                    div_spliter.className = "divSpliterOff";
                }else{
                    div_left.style.display = "block";
                    div_spliter.state = "on"
                    div_spliter.className = "divSpliter";
                }
            }
            
        </script></p>
    
    
        <link type="text/css" rel="stylesheet" href="ACScript/Style.css" />
        <link type="text/css" rel="stylesheet" href="ACScript/TopMenu.css" />
        <link type="text/css" rel="stylesheet" href="ACScript/WebControl.css" />
        <link type="text/css" rel="stylesheet" href="ACScript/DateInput.css" />
        
        <script language="javascript" type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/Hidden_Select.js"></script></p>
    
    
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>Script/StringVerify.js"></script></p>
    
    
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/TopMenu.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/ComFun.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/Report.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/rptMCL.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/rptDrugstore.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/DateInput.js"></script>
        
        <script type="text/javascript" src="<%=ETMS_APP_PATH %>ACScript/rptbase.js"></script></p>
    
    
    </head>
    <body style="text-align: center;">
        <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>
        <form id="form" name="form" runat="server" style="height: 100%;">
            <table cellspacing="0" cellpadding="0" width="99%" align="center" border="0">
                <tbody>
                    <tr>
                        <td class="topgray" height="3">
                        </td>
                    </tr>
                </tbody>
            </table>
            <div id="divMenu">
                <uc1:MainMenu ID="TopMenu1" runat="server"></uc1:MainMenu>
            
    
            <table height="3" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tbody>
                    <tr>
                        <td>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div id="divPageBackground" style="width: 99%; height: 100%; background-color: White;">
                <%-- <div id="divLeft" class="divLeft">
                
    
                <div id="divMain" class="divMain">
                
    --%>
                <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">
                    <tr>
                        <td id="divLeft" class="divLeft">
                            <div id="divLeft1" class="divLeft1">
                            
    
                            <div id="divLeft2" class="divLeft2">
                            
    
                            <br />
                            <div id="divLeftContent" class="divLeftContent">
                                <uc2:SystemBulletin ID="SystemBulletin1" runat="server" />
                                <br />
                                <uc3:SMS ID="SMS1" runat="server" />
                                <br />
                                <uc4:BriefCase ID="BriefCase1" runat="server" />
                                <br />
                                <uc5:Information ID="Information1" runat="server" />
                                <br />
                            
    
                        </td>
                        <td id="divSpliterTD" class="divSpliter" >
                            <div id="divSpliter"  class="divSpliter"  title="??????/??" state="on" &#111;nclick="SwitchLeftMenu();">
                            
    
                        </td>
                        <td class="divMain">
                            <div id="divMain1" class="divLeft1">
                            
    
                            <div id="divMain2" class="divLeft2">
                            
    
                            <div id="divMainContent" class="divMainContent">
                                <asp:ContentPlaceHolder ID="cphMain" runat="server">
                                </asp:ContentPlaceHolder>
                            
    
                        </td>
                    </tr>
                </table>
            
    
        </form>
        <iframe height="0px" width="0px" id="KepSessionFrame" src="<%=ETMS_APP_PATH %>AutoRefresh.aspx">
        </iframe>
    </body>
    </html>
    <script language="javascript" type="text/javascript">
        //?????
        
        //???LeftMenu
        initLeftMenu();
            
    </script>
    the codebehind sourcecode is:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;</p>
    
    
    namespace ETMS.Web
    {
        public partial class Site : System.Web.UI.MasterPage
        {</p>
    
    
            /// <summary>
            /// ??????
            /// </summary>
            public string ETMS_APP_PATH
            {
                get
                {
                    string strPath = Request.ApplicationPath;
                    string strLast = strPath.Substring(strPath.Length - 1);
                    if (strLast != "/")
                    {
                        strPath += "/";
                    }
                    return strPath;
                }
            }</p>
    
    
            protected void Page_Load(object sender, EventArgs e)
            {</p>
    
    
            }
        }
    }
    </p>
  2. #2

    RE: [CLOSED] ScriptManager throw exception in my masterpage

    Hi Pumpkin,

    I think adding a <ext:StyleContainer> and <ext:ScriptContainer> within your <head> should solve the problem. Place the StyleContainer near the top of the <head> and the <ext:ScriptContainer> at the bottom of the <head>. The following sample demonstrates...

    Example

    <head id="Head1" runat="server">
        <ext:StyleContainer runat="server" />
        
        <title>Page Title Here</title>
        
        <!-- Your Stuff Here -->
        
        <ext:ScriptContainer runat="server" />
    </head>
    Hope this helps.

    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] ScriptManager throw exception in my masterpage

    good, it worked.

Similar Threads

  1. Replies: 2
    Last Post: Jun 24, 2011, 5:33 PM
  2. Replies: 6
    Last Post: Dec 22, 2010, 1:41 PM
  3. [CLOSED] Ext Throw format error when using Portuguese
    By sharif in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 02, 2010, 4:52 PM
  4. Problem With ScriptManager on MasterPage
    By reiben in forum 1.x Help
    Replies: 1
    Last Post: Jun 12, 2010, 8:53 PM
  5. Replies: 6
    Last Post: Sep 24, 2009, 10:57 PM

Posting Permissions