Reputation: 525
So here is my problem: I have a webpage that is using an asp:TreeView control and a sitemap to draw a menu.
<asp:TreeView ID="CatalogTreeViewControl" runat="server" DataSourceID="dsSiteMap">
</asp:TreeView>
<asp:SiteMapDataSource runat="server" ID="dsSiteMap" ShowStartingNode="False" SiteMapProvider="MyXmlSiteMapProvider"/>
This works like a charm, but I want to use the asp:Menu control instead of the TreeView, så I do this:
<asp:TreeView ID="CatalogTreeViewControl" runat="server" DataSourceID="dsSiteMap" Visible="False">
</asp:TreeView>
<asp:Menu ID="Menu1" runat="server" DataSourceID="dsSiteMap"></asp:Menu>
<asp:SiteMapDataSource runat="server" ID="dsSiteMap" ShowStartingNode="False" SiteMapProvider="MyXmlSiteMapProvider"/>
But this results in the following error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
What am I doing wrong here?
Upvotes: 1
Views: 3640
Reputation: 1063
I got this problem a long time back. I moved my javascript from the head tag to a form tag and it fixed the problem. These links helped me a lot :
"The Controls collection cannot be modified because the control contains code blocks"
Upvotes: 1