ASPX Code
<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.DragDropSimple" CodeFile="DragDropSimple.aspx.cs" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain">
<div id="divTitle">
Using the SmartChart component's drag and drop features.</div>
<div id="divInstructions">
SmartChart provides drag and drop support in Internet Explorer 6+ or FireFox 2+ that can be used to re-arrange SmartChart
items. Drag an item and drop it over another to see this feature in action.
</div>
<p>
</p>
<swc:SmartChartPro ID="SmartChart1" Height="350" Width="660" MaxTextLength="35" OutputType="Html"
DataTitleFields="add1,add2,city,state,zip,county,phone,notes" DataNodeName="organization"
DataKeyField="key" DataFields="title,name,orgname" BoxColor="WhiteSmoke" BoxTextColor="Navy"
Font-Name="Verdana" Font-Size="8pt" TitleColor="MidnightBlue" MaxChildrenPerLevelGroup="6"
XSpacing="5" runat="server" DrawBorder="false" BorderWidth="1px" DrawShadows="True"
BoxGradient="True" OutputDirectory="ImageFolder" ShadowOffset="3" Font-Names="Verdana"
Font-Bold="True" ShadowColor="Silver" AllowEditing="True" AllowDrillDown="True"
AllowDeleting="True" AllowInserting="True" AllowDragDrop="True" HighlightChildrenOnMouseOver="True"
HighlightChildrenOnMouseOverColor="Red" SmartChartDirectory="ImageFolder" CleanupInterval="120"
BackgroundImage="images/seal.jpg" Title="HTML SmartChart" HasParentImagePath="../Images/up.gif"
HasChildrenImagePath="../Images/down.gif" HasChildrenImageVSpace="2" HasParentImageVSpace="6" ChartDepth="4">
</swc:SmartChartPro>
</asp:Content>
C# Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
namespace SmartWebControls.SampleCode {
/// <summary>
/// Summary description for OrgsTest2.
/// </summary>
public partial class DragDropSimple : System.Web.UI.Page {
protected System.Web.UI.HtmlControls.HtmlInputHidden upLevel;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.SmartChart1.SmartChartTextPreRender += new EventHandler<SmartChartEventArgs>(this.SmartChart1_SmartChartTextPreRender);
}
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
string xmlPath = Server.MapPath("~/SampleCode/SmartChartPro/XML/Orgs2.xml");
XmlDocument doc = new XmlDocument();
doc.Load(xmlPath);
SmartChart1.DataSource = doc;
SmartChart1.DataBind();
}
}
private void SmartChart1_SmartChartTextPreRender(object sender, SmartWebControls.SmartChartEventArgs e) {
if (e.Item.DataItem != null) {
//Check if the name of the column passed in the event is "title". If it is, change the background
//color of the text as well as its foreground color
if (e.Item.DataItem.Row.Table.Columns.Contains("title")) {
e.Item.BackColor = Color.Navy;
e.Item.ForeColor = Color.White;
}
}
}
}
}