Search
Creating Items on the Server Side

Create a root shape node when loading the page

  1. Switch to the Default.aspx.cs file.
  2. Add an if statement for checking IsPostBack; if it is false (loading the page for the first time), the root shape node should be drawn as specified in the CreateShapeNode method of the Factory class.
  3. Add the following code to the Page_Load event-handler:
    C#  Copy Code

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               Diagram diagram = diagView.Diagram;

               ShapeNode root = diagram.Factory.CreateShapeNode(10, 10, 24, 14);
               root.Shape = Shapes.RoundRect;
               root.Brush = new MindFusion.Drawing.SolidBrush(Color.White);
               root.Text = "root";
            }
        }
        ...
    }

In this source code, the Shape is specified as "RoundRect", a white SolidBrush assigned to the Brush, and the "root" Text should be displayed within the root shape node. 

  1. Execute the Website application.

The default browser is opened and the root shape node is drawn on the page.