ASPxMenu.Orientation Property
Gets or sets the direction in which to render the menu.
Namespace: DevExpress.Web
Assembly:
DevExpress.Web.v20.2.dll
NuGet Package:
DevExpress.Web
Declaration
Property Value
Use the Orientation property to specify the direction in which to render the menu control.
On the client side, you can control the menu orientation using the ASPxClientMenu.GetOrientation and ASPxClientMenu.SetOrientation methods.
Example
This sample illustrates how to keep the NavigateUrl of the item if there's a control in the ItemTemplateContainer of the ASPxMenu.
View Example
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication6._Default" %>
<%@ register Assembly="DevExpress.Web.ASPxEditors.v8.3" Namespace="DevExpress.Web.ASPxEditors"
TagPrefix="dxe" %>
<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxMenu" TagPrefix="dxm" %>
<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxSiteMapControl"
TagPrefix="dxsm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxm:aspxmenu ID="ASPxMenu1" runat="server" DataSourceID="ASPxSiteMapDataSource1"
Orientation="Vertical" OnDataBound="ASPxMenu1_DataBound">
<itemtemplate>
<dxe:aspxlabel ID="ASPxLabel1" runat="server" Text='<%#Container.Item.Text %>' Width="100px" Height="20px" Cursor="pointer">
</dxe:aspxlabel>
</itemtemplate>
</dxm:aspxmenu>
<dxsm:aspxsitemapdatasource ID="ASPxSiteMapDataSource1" runat="server" SiteMapFileName="~/web.sitemap" />
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxEditors;
namespace WebApplication6
{
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxMenu1_DataBound(object sender, EventArgs e) {
string url = "";
for (int i = 0; i < ASPxMenu1.Items.Count; i++) {
url = ASPxMenu1.Items[i].NavigateUrl;
ASPxLabel lab = ASPxMenu1.Items[i].FindControl("ASPxLabel1") as ASPxLabel;
if (lab != null) {
lab.ClientSideEvents.Click = "function(s,e){window.location = '" + url + "';}";
switch (lab.Text) {
case "Yahoo!": {
lab.BackColor = System.Drawing.Color.LightPink;
break;
}
case "MSN": {
lab.BackColor = System.Drawing.Color.LightSkyBlue;
break;
}
case "Google": {
lab.BackColor = System.Drawing.Color.LightSeaGreen;
break;
}
}
}
}
}
}
}
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="WebApplication6._Default" %>
<%@ register Assembly="DevExpress.Web.ASPxEditors.v8.3" Namespace="DevExpress.Web.ASPxEditors"
TagPrefix="dxe" %>
<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxMenu" TagPrefix="dxm" %>
<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxSiteMapControl"
TagPrefix="dxsm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxm:aspxmenu ID="ASPxMenu1" runat="server" DataSourceID="ASPxSiteMapDataSource1"
Orientation="Vertical" OnDataBound="ASPxMenu1_DataBound">
<itemtemplate>
<dxe:aspxlabel ID="ASPxLabel1" runat="server" Text='<%#Container.Item.Text%>' Width="100px" Height="20px" Cursor="pointer">
</dxe:aspxlabel>
</itemtemplate>
</dxm:aspxmenu>
<dxsm:aspxsitemapdatasource ID="ASPxSiteMapDataSource1" runat="server" SiteMapFileName="~/web.sitemap" />
</div>
</form>
</body>
</html>
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports DevExpress.Web.ASPxEditors
Namespace WebApplication6
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub ASPxMenu1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
Dim url As String = ""
For i As Integer = 0 To ASPxMenu1.Items.Count - 1
url = ASPxMenu1.Items(i).NavigateUrl
Dim lab As ASPxLabel = TryCast(ASPxMenu1.Items(i).FindControl("ASPxLabel1"), ASPxLabel)
If lab IsNot Nothing Then
lab.ClientSideEvents.Click = "function(s,e){window.location = '" & url & "';}"
Select Case lab.Text
Case "Yahoo!"
lab.BackColor = System.Drawing.Color.LightPink
Exit Select
Case "MSN"
lab.BackColor = System.Drawing.Color.LightSkyBlue
Exit Select
Case "Google"
lab.BackColor = System.Drawing.Color.LightSeaGreen
Exit Select
End Select
End If
Next i
End Sub
End Class
End Namespace
See Also