.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

.NET 4.0: Inside UserControl Menu.Items.Add(...) cause 'HttpException (0x80004005)'

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

When using .NET 4.0 there seems to be an issue - inside any UserControl Menu.Items.Add(...) cause 'HttpException (0x80004005)':


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) +11242224
   System.Web.UI.Control.PreRenderRecursiveInternal() +113
   System.Web.UI.Control.PreRenderRecursiveInternal() +222
   System.Web.UI.Control.PreRenderRecursiveInternal() +222

View Complete Post

More Related Resource Links

How to see all items inside a menu

I have a specific problem that considers a menu which I am building inside a VS2005. I have too much menu items, so I can't see them all in Designer view. Can someone pleease tell me where I can set some sort of property so I can see them all. Or is there a way to engage arrows in menu that we can use to see all items. I did' not had this problem inside VS 2008 nor 2010. Thx

Menu items of Welcome control behaves incorrect in non-IE browsers.


We are using wss 3.0 sp2

I am referring to the welcome control that is part of standard sharepoint pages. This is the in the masterpage. The welcome contrrol has options such as 'sign-in as different user' , 'signout' and so on. When user takes the mouse and tries to click on the sub-menu it doesn't work as if the menu item is not getting focussed (however up/down arrow with keyboard works fine). 

I know that sharepoint sites are not best when viewed with firefox, safari, chrome etc  but is there a fix for this? Is it do with 'z' index setting or something? Can this be fixed through javascript?  

Please share your views/solution.


How to Make CSS for Hyperlinks NOT Affect Menu Items


VWD 2008 Express.

I have the following CSS in my DefaultStyleSheet.css file.  I want this to only apply to text hyperlinks (like links to web sites or email addresses) but NOT to my asp:menu items.  I am finding that although I have defined my asp:menu items in the menu properties, the colors in the text in the menu tabs get overridden by the CSS below.  How can I make this not happen?  Thanks for any help.


{color:#6F928B; text-decoration: none}


{color: #660066;}


Web zone inside of a web usercontrol.

Hi guys, I need to add web zones to a user control where the users can added web part inside of the webusercontrol.ascx. I have try many ways but it does not work. Does Someone have some idea how to have a user control where users can add web part inside of it? Thanks!! HANK    

Menu with Static and Dynamic Menu Items

I need to populate a menu with static and dynamic (at runtime) menu items.  I know this issue has been posted before, but I haven't seen anything with a date newer than 2009. This is what I want to do: <Menu> <Menu.ItemsSource>                     <CompositeCollection>                      <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item 2" /> <MenuItem Header="Menu Item 3" />                         <CollectionContainer Collection="{Binding MyMenuItems}" />                     </CompositeCollection> </Menu.ItemsSource> </Menu>   The posts every where say the issue is that CompositeCollection is not freezable.  Regardless of that arguement, has anyone come up with a good solution.  I don't want to create it all in code behind because it is a decent size menu with separators, etc.  This seems like something that should have been fixed or have a decent work round by now.   Thanks. 

Customize SharePoint Library Menu Items

Hi, In a library with file, the menu items available for any file is: View Properties, Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Send To, Check Out, Workflows, Alert Me . Now, I want to get rid of Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Check Out . Added to this is the need to remove the option in the Actions menu that states "Open With Windows Explorer " and finally the "Upload " menu is to go out. Any JScript for this or a file I need to edit to get this result? I need this because the business wants it out, its bordering on security. ThanksYou've only got one life; help as many people as you can, and enjoy it while it lasts.

Tab panel inside usercontrol cut off in ie6 and ie7

Hi,can anyone shed me some light on this issue.I use the tabpanel and place it in a usercontrol. but the text in the tab header are cut off when opened in IE6 and IE7. in mozilla this is working properly. i am loading this usercontrol in a webpart so i can add it in any page in my site.can someone help me. Thanks

how to access items inside Sharepoint List Folder

hi all i have a list with structure as below  QuckList(List)                A(Folder)                       1(List Items)                       2(List Items)                B(Folder)                        1(List Items)   i have to display the List items inside the folder in drop down   i am able to access the folder as Splistitem, but not able to access the items inside the folder   any ideas how to access the items inside the List Folder   ragava_28

How to make context menu as non selectable when the usercontrol is active

I am having a context menu displayed when i right click on a node of a treeview. Suppose my treeview is as follows Root |->some.txt |-> Child(For some.txt) |-> Child1(child for Child) If i right click on Child1 i will have an option as AddNew. If the user selects i will show a user control form for the user displayed in a panel. What i need is if the user selects the option as Child1 and if the user control is active and when the user again right clicks

Menu Items for SPMenu

Hi All, I have developed application page which contains spgridview. And I have used SPMenuField for displaying menu items for files and folders. What my problem is, for both  files and folders I am getting same menu items. But I need to display different menu items for folders and files based on condition. How can I achieve this? Let me know if you have any queries. Regards, Kumar.

How To Space Menu Items Evenly

I'm using Visual Studio 2008. I have a asp menu in a cell in a table. The menu has 3 items as shown below This works fine however, how do you put more spacing (even spacing) bewteen the items? The items are too close together.   <tr>        <td>        </td>        <td>        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"                 style="margin-right: 8px">            <Items>                <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>                <asp:MenuItem Text="Solutions" Value="Solutions"></asp:MenuItem>                <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>            </Items>  

After building Installer - Items missing from Menu

Not sure if this is the best or correct forum so please excuse me and let me know where I should be posting my question, thanks. I have built my Windows Forms Application and it works fine... I now have to build an Installer project, which I have done with  reasonable success... EXCEPT FOR... The Menu Group and item do NOT appear in the Menu system.  The Desktop item appears correctly and the structure is there but no menu items appear.  I created the shortcut for the User's Desktop and User's Program Menu. (Using VS2008, C#, .NET 3.51, Access (DB), Forms, Installer project.) What am I missing SquireDude

Collect Menu/Submenu/Popupmenu items

Dear Sir, I am using VS2005 and SQL Server2000 I have a project where lot of Menu/Submenu/Popupmenu items. Now I want to have all Menu/Submenu/Popupmenu items in a list box of the project. I want to do this for create user access control to my project. so that selective group can access selected feature and Menu/Submenu/Popupmenu items. How can I do this ?????? / or is there any other way to control this access????

Is it possible to disable context menu items based on the selection on Treeview

I will have some sort of nodes for a treeview as follows Root |-> some.txt(A text file which was added at runtime) |->Child(child for some.txt) |-> child1(child for child) I designed my context menu with some options as New and Remove What i need is when i righclick on Root, child or child i would like to disable the Remove option

Vertical Align Menu Items when RenderingMode=List


I am having problems getting my Menu Items to align vertically in the middle when I set my rendering mode = list.

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="list" CssClass="AspNet-Menu">
                <asp:MenuItem NavigateUrl="#" Text="Menu 1" Value="Menu 1"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 2" Value="Menu 2"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 3" Value="Menu 3"></asp:MenuItem>

css code for list

/* MENU */

.AspNet-Menu ul li{ width:60px; height:30px; background-color:Silver; vertical-align:middle;}
.AspNet-Menu ul li a
	color: Red;

But if i set the rendering mode to table it works fine...

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="table" CssClass="AspNet-Menu">

Navigate Menu asp Control Add Items (HOW?) c#


I feel like a complete idiot!! :)

I have a asp.net menu control on a default.aspx page

I want to add items to this menu control using the code behind file (C#)

How do I do this?

My menu id is mnuHeader

YES, newB question .. LOL


Thanks for your help in advance!!! 

Enabling individual items inside disabled listviewitems

I'm struggling with the following and would appreciate some help:

I have a number of items in a listview, some of which may be in a readonly state. When in readonly state, the items are disabled. However, I need the user to be able to remove them by clicking a button which is displayed using a celltemplate on a gridviewcolumn. By default this is disabled by default and setting IsEnabled="true" on the item itself does not enable it regardless of the state of the container.

I'd also like the user to be able to select the item to remove it in a multiselect mode. However selection is also disabled by default. What is the best way to achieve both ways of removing the item?

The item is disabled inside a user control using the following:

ListBoxItem listBoxItem = (Item is int) ? GetListBoxItemFromIndex((int)Item) : GetListBoxItemFromItem(Item);
if (listBoxItem != null)
 listBoxItem.IsEnabled = Enable;

The button is defined in XAML as follows. It is a
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend