ERRORS: control contains code blocks (i.e. <% ... %>)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
Why is this happeing? how do I fix it, it occurrs during ADMINISTRATION VIEW OF CATEGORIES.

Server Error in '/NopCommerceStore' Application.
--------------------------------------------------------------------------------

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
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.Add(Control child) +8677431
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() +208
   System.Web.UI.Control.SaveViewStateRecursive() +8682482
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Page.SaveAllState() +168
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1099
14 年 前
Hi,

Looks to me like you have enabled CSS Friendly adapters for the TreeView control.

Open up App_Browsers/CSSFriendlyAdapters.browser and comment out:

<adapter controlType="System.Web.UI.WebControls.TreeView" adapterType="CSSFriendly.TreeViewAdapter" />

This will then fix your problem.

Thanks
Ben
13 年 前
Hello,
I had the same problem.

In my mind, no need to comment out the CSSFriendly, instead, better to find reason and a solution to fix it.

The cause of this error are code blocks with '=' signs in Markup page [<%= %>]. Try to find them in markup page and move them to code behind;
e.g.:
Markup: <a href='<%= ResolveUrl("~/url.ext")%>'>Link Text</a>

Replace above with:
<a id="link1" runat="server">Link Text</a>
Code Behind:
link1.ResolveUrl("~/url.ext");

Attention: Your markup tag should contain both ID="anyID" and RUNAT="SERVER" to be accessible in code behind.

May Allah bless you all,

As for those who believe and do good works, He will pay them their wages in full. Allah does not love the harm doers. [Koran 3.57]
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.