The company wants to create an organizational structure chart or a mind map. After finding a lot on the internet, it finally finds a suitable C # organizational structure chart control.
First, display the image to see the effect:
Level:
Vertical:
Usage:
1. After referencing dll in a website or Web application, write the following code on the page:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "MyTest. aspx. cs" Inherits = "OrgChartWebControl. Gallery. MyTest" %>
<% @ Register TagPrefix = "oc" Namespace = "Whidsoft. WebControls" Assembly = "Whidsoft. WebControls. OrgChart" %>
<Html>
<Head runat = "server">
<Title> Mind Map </title>
<Style type = "text/css">
. Alink a, a: hover, a: visited {
Color: Black;
Text-decoration: none;
}
</Style>
</Head>
<Body>
<Form id = "Form1" method = "post" runat = "server">
<Div class = "alink">
<Oc: orgchart id = "OrgChart1" style = "z-index: 101; left: pixel; position: absolute; top: 88px"
Runat = "server" LineColor = "Silver" Width = "100%" Height = "100%" ChartStyle = "Vertical" ToolTip = "test"> </oc: orgchart>
</Div>
</Form>
</Body>
</Html>
The background code is written as follows:
Using System;
Using System. Collections. Generic;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using Whidsoft. WebControls;
Namespace OrgChartWebControl. Gallery
{
/*---------------------------------------------
* Page Description:
* Created by: shopping
* Creation date: 14:57:28
* Company Name:
---------------------------------------------*/
Public partial class MyTest: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
String style = Request. QueryString ["style"];
If (style = null | style = "")
{
Style = "1 ";
}
If (! IsPostBack)
{
// Each node in the organization chart is an OrgNode. Each attribute is the display name and tips respectively.
OrgNode orgNode = new OrgNode ();
OrgNode. Text = "luobao line ";
OrgNode. Description = "this is the tip of the organization chart ";
OrgNode. NavigateUrl = "http://www.whidsoft.cn ";
OrgNode. UnderDesc = "accumulative power: 10 million degrees, accounting for 100% of the power consumed by the line ";
// Create nodes
OrgNode OrgNode1 = new OrgNode ();
OrgNode1.Text = "station lighting power ";
OrgNode1.Description = "this is ";
OrgNode1.UnderDesc = "accumulative power: 0.55 million degrees, accounting for 65% of the power consumed by the line ";
OrgNode OrgNode11 = new OrgNode ();
OrgNode11.Text = "station 1 ";
OrgNode11.Description = "this is ";
OrgNode11.UnderDesc = "accumulative power: 0.33 million degrees, accounting for 13% of the power consumed by the line ";
OrgNode OrgNode12 = new OrgNode ();
OrgNode12.Text = "station 2 ";
OrgNode12.Description = "this is ";
OrgNode12.UnderDesc = "accumulative power usage: 1.33 million degrees, accounting for 33% of total power usage ";
OrgNode OrgNode13 = new OrgNode ();
OrgNode13.Text = "Station 3 ";
OrgNode13.Description = "this is ";
OrgNode13.UnderDesc = "accumulative power usage: 0.13 million degrees, accounting for 33% of total power usage ";
OrgNode1.Nodes. Add (OrgNode11 );
OrgNode1.Nodes. Add (OrgNode12 );
OrgNode1.Nodes. Add (OrgNode13 );
OrgNode. Nodes. Add (OrgNode1 );
OrgNode OrgNode2 = new OrgNode ();
OrgNode2.Text = "Traction Power ";
OrgNode2.Description = "this is ";
OrgNode2.UnderDesc = "accumulative power: 0.13 million degrees, accounting for 11% of the power consumed by the line ";
OrgNode OrgNode21 = new OrgNode ();
OrgNode21.Text = "1-segment traction ";
OrgNode21.Description = "this is ";
OrgNode OrgNode22 = new OrgNode ();
OrgNode22.Text = "2-segment traction ";
OrgNode22.Description = "this is ";
OrgNode2.Nodes. Add (OrgNode21 );
OrgNode2.Nodes. Add (OrgNode22 );
OrgNode. Nodes. Add (OrgNode2 );
OrgNode OrgNode3 = new OrgNode ();
OrgNode3.Text = "service section ";
OrgNode3.Description = "this is 3 ";
OrgNode3.UnderDesc = "accumulative power: 3.45 million degrees, accounting for 54% of the power consumed by the line ";
OrgNode OrgNode31 = new OrgNode ();
OrgNode31.Text = "Repair ";
OrgNode31.Description = "this is 3 ";
OrgNode OrgNode32 = new OrgNode ();
OrgNode32.Text = "Car Washing and sewage ";
OrgNode32.Description = "this is 3 ";
OrgNode OrgNode33 = new OrgNode ();
OrgNode33.Text = "Integrated Office Building ";
OrgNode33.Description = "this is 3 ";
OrgNode3.Nodes. Add (OrgNode31 );
OrgNode3.Nodes. Add (OrgNode32 );
OrgNode3.Nodes. Add (OrgNode33 );
OrgNode. Nodes. Add (OrgNode3 );
OrgNode OrgNode4 = new OrgNode ();
OrgNode4.Text = "Management Center ";
OrgNode4.Description = "this is 3 ";
OrgNode4.UnderDesc = "accumulative power usage: 2.34 million degrees, accounting for 34% of total power usage ";
OrgNode OrgNode41 = new OrgNode ();
OrgNode41.Text = "office ";
OrgNode41.Description = "this is 3 ";
OrgNode OrgNode42 = new OrgNode ();
OrgNode42.Text = "commercial ";
OrgNode42.Description = "this is 3 ";
OrgNode OrgNode43 = new OrgNode ();
OrgNode43.Text = "Data Center ";
OrgNode43.Description = "this is 3 ";
OrgNode4.Nodes. Add (OrgNode41 );
OrgNode4.Nodes. Add (OrgNode42 );
OrgNode4.Nodes. Add (OrgNode43 );
OrgNode. Nodes. Add (OrgNode4 );
OrgChart1.Node = orgNode;
OrgChart1.ChartStyle = (style = "1 ")? Whidsoft. WebControls. Orientation. Vertical: Whidsoft. WebControls. Orientation. Horizontal;
}
}
}
}
Source code download: Click to download the control source code
This article is mainly used to add to favorites for personal learning. For more information, see the famous source. Thank you!