Search
Adding Simple Code to a Page

Adding code to Default.aspx.cs (code-behind code)

Double-click the Default.aspx.cs file in the Solution Explorer to open it in the Code Editor.

  1. Create a shape node when loading the page

Add the following code to the Page_Load event-handler:

C#(Default.aspx.cs)  Copy Code

protected void Page_Load(object sender, EventArgs e)
    {
        DiagramView1.Diagram.DefaultShape = Shapes.Rectangle;
        ShapeNode n = DiagramView1.Diagram.Factory.CreateShapeNode(12, 12, 45, 22);
        n.Text = "My first NetDiagram node";
    }

  1. Press CTRL+F5 to execute the web application.