How to handle/debug HttpExceptions properly?
<p>So i recently been getting this httpexeption when trying to view the site i've been working on through iis7. The error is below:</p>

<blockquote>
  <p>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.</p>
  
  <p>Exception Details: System.Web.HttpException: The Controls collection
  cannot be modified because the control contains code blocks (i.e. &lt;%
  ... %>).</p>
  
  <p>Source Error: </p>
  
  <p>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.</p>
  
  <p>Stack Trace: </p>
  
  <p>[HttpException (0x80004005): The Controls collection cannot be
  modified because the control contains code blocks (i.e. &lt;% ... %>).]<br>
  System.Web.UI.ControlCollection.AddAt(Int32 index, Control child)
  +8689794    Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +132</p>
  
  <p>[HttpException (0x80004005): Please, see whether wrapping the code
  block, generating the exception, within RadCodeBlock resolves the
  error.]    Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control
  initiator, Control updated) +180<br>
  Telerik.Web.UI.RadAjaxControl.PerformRender() +375<br>
  Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer,
  Control page) +1222<br>
  Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter
  writer, Control page) +95<br>
  System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
  ICollection children) +256<br>
  System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19<br>
  System.Web.UI.Page.Render(HtmlTextWriter writer) +29<br>
  System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer)
  +21    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +8703529<br>
  System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
  ControlAdapter adapter) +99<br>
  System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25<br>
  System.Web.UI.Page.ProcessRequestMain(Boolean
  includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  +1266</p>
</blockquote>

<p>When doing research on the problem, the only viable solution i have seem to of found was wrap the javascript inside a radcodeblock or use a <code>&lt;span runat="server"&gt;</code>. I have tried both of these methods and neither seems to work. I'm also slightly confused as to why i would be getting this error since none of the javascript implemented by the previous developer of this site contains no items as far as i can tell that use <code>&lt;%...%&gt;</code>. </p>

<p>Furthermore, i've gone ahead and checked all of the controls in my pages to ensure that the above condition that it is complainning about is in fact not occurring. In other words as far as i can tell there is no place in the code where <code>&lt;%...%&gt;</code> is being used other than in the declaration of the page. i.e:</p>

<pre><code> &lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginPage.aspx.cs" Inherits="Datamart.UI.Reporting.Web.LoginPage" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" ValidateRequest="False" %&gt;
&lt;%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %&gt;
</code></pre>

<p>So i was wondering what it is i could possibly be doing wrong or what would be the next step in finding out where and what exactly my problem is. Where i thought the error was occuring is located below:</p>

<pre><code>&lt;telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"&gt;  
            &lt;script type="text/javascript"&gt;
            function onTabSelecting(sender, args) 
            {
                if ( args.get_tab().get_pageView()) 
                {
                    if (args.get_tab().get_pageView().get_id()) 
                    {
                        args.get_tab().set_postBack( false );
                    }
                }
            }
            function StopPropagation(e) 
            {
                //cancel bubbling 
                e.cancelBubble = true;
                if (e.stopPropagation)
                    e.stopPropagation();
            }

            //the following code use radconfirm to mimic the blocking of the execution thread.
            //The approach has the following limitations:
            //1. It works inly for elements that have *click* method, e.g. links and buttons
            //2. It cannot be used in if(!confirm) checks
            window.blockConfirm = function(text, mozEvent, oWidth, oHeight, callerObj1, oTitle) 
            {
                var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually 
                //Cancel the event 
                ev.cancelBubble = true;
                ev.returnValue = false;
                if (ev.stopPropagation) 
                    ev.stopPropagation();
                if (ev.preventDefault) 
                    ev.preventDefault();

                //Determine who is the caller 
                var callerObj = ev.srcElement ? ev.srcElement : ev.target;

                //Call the original radconfirm and pass it all necessary parameters
                if (callerObj) 
                {
                    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.
                    var callBackFn = function(arg) 
                    {
                        if (arg) 
                        {
                            callerObj["onclick"] = "";
                            if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz 
                            else if (callerObj.tagName == "A") //We assume it is a link button! 
                            {
                                try 
                                {
                                    eval(callerObj.href)
                                }
                                catch (e) { }
                            }
                        }
                    }

                    radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
                }
                return false;
            }
            function noBack() 
            {
                window.history.forward(); 
            }
            noBack();
            window.onload = noBack;
            window.onpageshow = function(evt) 
            {
                if (evt.persisted) noBack(); 
            }
            window.onunload = function() 
            {
                void (0);
            }
            &lt;/script&gt;          
        &lt;/telerik:RadScriptBlock&gt;
</code></pre>

<p>This is found in the body of my page, but i have tried moving it to the bottom of the page as well as to the header since that was found to be a possible solution for others but to no avail.</p>

<p>Any help or suggestions are greatly appreciated. Thank you.</p>
