ASPX Code
<%@ Page Culture="fr-FR" UICulture="fr-FR" Title="Localizing" Language="C#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" AutoEventWireup="true" CodeFile="Localizing.aspx.cs" Inherits="Localizing" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" Runat="Server">
<div id="divTitle">
Using the SmartChart component's Localization Features.</div>
<div id="divInstructions">
SmartChart provides localization support to change menu values,button values, etc. for other languages. This
example demonstrates how to leverage localization support so show French values as a menu is displayed. Localization support
is added by creating a SmartWebControls.SmartChart.fr-FR.resx (or other culture) file into the App_GlobalResources folder of an ASP.NET Website.
</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"
EditMenuWidth="0px">
</swc:SmartChartPro>
</asp:Content>
C# Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using SmartWebControls;
using System.Drawing;
public partial class Localizing : 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;
}
}
}
}