ASPxSiteMapDataSource.LoadFromFile(String) Method
Loads the site map data from the specified file into the current data source.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Parameters
Name | Type | Description |
---|---|---|
siteMapFileName | String | A String value specifying the name of the file which contains the site map data to load. |
Example
This example demonstrates how to bind the ASPxMenu control to a data source.
In this demo, the menu control is bound to a ASPxSiteMapDataSource type data source. The ASPxSiteMapDataSource allows you to load site map data at runtime from a specific file by using the ASPxSiteMapDataSource.LoadFromFile
method.
Note that the menu’s ASPxMenuBase.ItemDataBound event can be used to manipulate the values being assigned to the properties of a menu item during its data binding. Look at the ASPxMenuBase.ItemDataBound event’s implemetation, demonstrating how to assign a specific value to a menu item’s MenuItem.Text property, by combining the text to be assigned to this property with the value of the specific result attribute of the corresponding site map node which the item is being bound to.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxNavBar"
tagprefix="dxnb" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxMenu" tagprefix="dxm" %>
<%@ Register assembly="DevExpress.Web.v8.3, Version=8.3.2.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a" 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">
<script runat="server">
protected void Page_Load(object sender, EventArgs e){
ASPxSiteMapDataSource1.LoadFromFile("~/App_Data/MenuCup2006.sitemap");
}
protected void ASPxMenu1_ItemDataBound(object source,
DevExpress.Web.MenuItemEventArgs e) {
SiteMapNode node = e.Item.DataItem as SiteMapNode;
if (node != null)
e.Item.Text = "<b>" + node["result"] + "</b> " + e.Item.Text;
}
</script>
<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 EnableViewState="False" DataSourceID="ASPxSiteMapDataSource1"
EncodeHtml="False" id="ASPxMenu1" runat="server" AllowSelectItem="True"
OnItemDataBound="ASPxMenu1_ItemDataBound" Orientation="Vertical">
</dxm:ASPxMenu>
<dxsm:ASPxSiteMapDataSource ID="ASPxSiteMapDataSource1" runat="server" />
</div>
</form>
</body>
</html>