This sample demonstrates how to bind the ASPxTabControl to data without manually setting the control's data-related properties.
The ASPxTabControl's data source is set to an XmlDataSource component that is used to retrieve data from an XML file. The XmlDataSource's XPath property is defined explicitly.
Based on the source data, the ASPxTabControl populates its Tabs collection with automatically created Tab objects. Tab object characteristics (such as text, image, navigate location, tooltip text, etc.) are obtained from the XML file's node attributes.This example demonstrates the ASPxTabControl's ability to automatically retrieve tab characteristics from node attributes whose names coincide with property names of a Tab object. For this purpose, node attributes are named asActiveTabImageUrl,Name,NavigateUrl, TabImageUrl, Text and ToolTip in this demo. Note that the name match is not case sensitive.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v10.1, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxTabControl" tagprefix="dx" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<dx:ASPxTabControl ID="ASPxTabControl1" runat="server"
DataSourceID="XmlDataSource1">
</dx:ASPxTabControl>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/TabControlDataSource.xml" XPath="platforms/*"></asp:XmlDataSource>
</form>
</body>
</html>
<?xml version="1.0" encoding="utf-8" ?>
<platforms>
<platform Name="WinForms" NavigateUrl="javascript: void(0);" TabImageUrl="~/Images/WinForms_ini.png" ActiveTabImageUrl="~/Images/WinForms_Active.png" Text="WinForms" ToolTip="WinForms Controls and Libraries"></platform>
<platform Name="ASP" NavigateUrl="javascript: void(1);" TabImageUrl="~/Images/ASP_ini.png" ActiveTabImageUrl="~/Images/ASP_Active.png" Text="ASP.NET Controls" ToolTip="ASP.NET Controls and Libraries"></platform>
<platform Name="VCL" NavigateUrl="http://devexpress.com/Products/VCL/" TabImageUrl="~/Images/VCL_ini.png" ActiveTabImageUrl="~/Images/VCL_Active.png" Text="Delphi VCL Controls" ToolTip="Delphi and C++ Builder Controls"></platform>
</platforms>
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
End Class
<?xml version="1.0" encoding="utf-8" ?>
<platforms>
<platform Name="WinForms" NavigateUrl="javascript: void(0);" TabImageUrl="~/Images/WinForms_ini.png" ActiveTabImageUrl="~/Images/WinForms_Active.png" Text="WinForms" ToolTip="WinForms Controls and Libraries"></platform>
<platform Name="ASP" NavigateUrl="javascript: void(1);" TabImageUrl="~/Images/ASP_ini.png" ActiveTabImageUrl="~/Images/ASP_Active.png" Text="ASP.NET Controls" ToolTip="ASP.NET Controls and Libraries"></platform>
<platform Name="VCL" NavigateUrl="http://devexpress.com/Products/VCL/" TabImageUrl="~/Images/VCL_ini.png" ActiveTabImageUrl="~/Images/VCL_Active.png" Text="Delphi VCL Controls" ToolTip="Delphi and C++ Builder Controls"></platform>
</platforms>
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.v10.1, Version=10.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxTabControl" tagprefix="dx" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<dx:ASPxTabControl ID="ASPxTabControl1" runat="server"
DataSourceID="XmlDataSource1">
</dx:ASPxTabControl>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/TabControlDataSource.xml" XPath="platforms/*"></asp:XmlDataSource>
</form>
</body>
</html>