所以我最近一直在試圖查看我一直在通過iis7工作的網站時獲得這個httpexeption。下面的錯誤是:如何正確處理/調試HttpExceptions?
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.AddAt(Int32 index, Control child) +8689794 Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +132[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
Telerik.Web.UI.RadAjaxControl.PerformRender() +375
Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1222
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +95
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer) +21 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +8703529
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
在做對這個問題的研究,唯一可行的解決方案,我有似乎發現了包裹的javascript radcodeblock內或使用<span runat="server">
。我已經嘗試了這兩種方法,似乎都沒有工作。我也有點困惑,爲什麼我會得到這個錯誤,因爲沒有任何由本網站以前的開發人員實施的JavaScript包含任何項目,據我所知,使用<%...%>
。
此外,我已經提前檢查並檢查了頁面中的所有控件,以確保其抱怨的上述情況實際上並未發生。換句話說,據我所知,在代碼中沒有任何地方使用<%...%>
,而不是在頁面的聲明中。即:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginPage.aspx.cs" Inherits="Datamart.UI.Reporting.Web.LoginPage" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" ValidateRequest="False" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
所以我想知道它是什麼我可能是做錯了還是什麼將是找出哪裏和我的究竟是什麼問題的下一個步驟。當我認爲是存在的位於下面的錯誤:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
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);
}
</script>
</telerik:RadScriptBlock>
這在我的頁面的正文中,但我已經嘗試過移動到頁面的底部,以及在頭部,因爲被發現成爲其他人可能的解決方案,但無濟於事。
任何幫助或建議,非常感謝。謝謝。