Showing posts with label Menu. Show all posts
Showing posts with label Menu. Show all posts

Monday, November 19, 2012

Add Menu to MDI Parent Form

MDI (Multiple-Document Interface) applications should have a MDI Parent form which will act as the parent for all other forms in the application. In this post we shall see on how to add a Menu control to an MDI Parent Form.

Tuesday, April 3, 2012

Asp.Net - MultiView Control & Menu Controls

When we need to display more controls in a single page and control their visibility based on conditions the MultiView control comes in handy. The Multiview control can contain a list of Views each of which can contain any number of controls.

This control comes in handy, when different users have difference View preferences, we can create a number of customized views and display a specific view to a set of users based on their view preferences.

The View to be displayed can be controlled using the ActiveViewIndex property or SetActiveView method. At any given time only one view can be active, only the contents of the ActiveView are rendered to the client.

We can use the Menu control with the MultiView control to provide a View Navigation.

<asp:Menu ID="mnuMain"
runat="server"
Orientation="Horizontal"
onmenuitemclick="mnuMain_MenuItemClick">
<Items>
<asp:MenuItem Text="Menu1 |" Value="Menu1">asp:MenuItem>
<asp:MenuItem Text="Menu2 |" Value="Menu2">asp:MenuItem>
<asp:MenuItem Text="Menu3 |" Value="Menu3">asp:MenuItem>
<asp:MenuItem Text="Menu4 |" Value="Menu4">asp:MenuItem>
<asp:MenuItem Text="Menu5 |" Value="Menu5">asp:MenuItem>
Items>
<StaticMenuStyle CssClass="MenuNormal" />
<StaticSelectedStyle CssClass="MenuActive" />
asp:Menu>

Now we have defined the Menu control for Navigation, we shall now define the MultiView control and place different views under the Control.

<asp:MultiView
id="mViewProjects"
runat="server"
ActiveViewIndex="0">
<asp:View ID="view1" runat="server">
<table style="background-color:#CCFFFF; width:100%;">
<tr>
<td class="Heading">View1 Content Here…<td>

</tr>
</table>
</asp:View>
<asp:View ID="view2" runat="server">
<table style="background-color:#CCFFFF; width:100%;">
<tr>
<td class="Heading">View2 Content Here…
</td>

</tr>
</table>
</asp:View>
</asp:MultiView>

We have now defined the Menu control and the MultiView controls, next we will have to link the display of the various views in the MultiView to the Menu control, to do so, use the MenuItemClick event of the Menu control as follows.

protected void mnuMain_MenuItemClick(object sender, MenuEventArgs e)
{

switch (e.Item.Value.ToString())

{

case "Menu1":

{

mViewProjects.SetActiveView(view1);

break;

}

case "Menu1":

{

mViewProjects.SetActiveView(view2);

break;

}

}

}

We are done, now in clicking the various Menu options the corresponding View gets rendered and the controls defined in the View are displayed in the Browser.

That’s it, we have seen how to user Menu and MultiView controls to produce a navigations system.