Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm setting the MenuItems for an asp:Menu dynamically. So here's the ASPX:

XML
<asp:Menu ID="FlowMenu1" runat="server" CssClass="menu" EnableViewState="false" Visible="true" IncludeStyleBlock="false" Orientation="Horizontal" OnMenuItemClick="FlowMenu1Clicked">
    </asp:Menu>


... and here's a snippet from the code-behind:

C#
MenuItem saveDraft1 = new MenuItem();
saveDraft1.Text = "Save Draft";
saveDraft1.Value = " ";

if ( ((position == "Employee") && ((documentState == "WORKING") ||
                                   (documentState == "DRAFT"))) ||
     ((position == "First Evaluator") && ((documentState == "NEW") ||
                                          (documentState == "REVIEW") ||
                                          (documentState == "CONVERSATION") ||
                                          (documentState == "CRITIQUE"))) ||
     ((position == "Second Evaluator") && ((documentState == "FEEDBACK") ||
                                           (documentState == "SCRUTINY"))) ||
     ((position == "Third Evaluator") && ((documentState == "REACTION") ||
                                          (documentState == "INSPECTION"))) )
{
    FlowMenu1.Items.Add(saveDraft1);
}


I've seen these problems suggested, but none of them have worked:

* The OnMenuItemClick procedure is defined (but when I put a breakpoint at the beginning of the procedure, it doesn't even seem like the event is firing)

* There's no AutoPostBack property to set on either the Menu or the MenuItem objects

* There's no NavigateUrl property set on the MenuItems (nor do I want there to be)

* There's no ImageUrl property set on the MenuItems (nor do I want there to be)

* Both the MenuItem.Text and the MenuItem.Value properties are set for all MenuItems

I've tried everything I can think of, including putting the menu control on its own panel. Thank you for any insight you can lend.
Posted
Comments
V. 16-Sep-14 4:58am    
Stupid question but shouldn't you hook up an event handler (onclick) to the saveDraft1 object? You added one to the FlowMenu1 object, but not to the dynamically created item...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900