Articles in this section
Category / Section

Can I set an image as the background for the Diagram Web Control?

1 min read

Can I set an image as the background for the Diagram Web Control?

Yes, it is possible to set an image as the background for the DiagramWebControl. The DiagramWebControl shares its architecture with the Windows Forms version of the product, and most of the functionality available in the Windows version of Essential Diagram is available in the Web Control as well.

The following code shows how to set a background image for the Diagram Web Control,

C#

private void Page_Load(object sender, System.EventArgs e)

{

if(this.IsPostBack == false)

{

// To Set a background image for the DiagramWebControl...

// First create a Bitmap object for the background image

string path = Server.MapPath("/syncfusion/");

path = path + @"\Web\Diagram.Web\Samples\ScriptyClient\CS\bin\suiteimage.jpg";

System.Drawing.Bitmap background = new Bitmap(path);

// Now assign the image to the diagram model's BackgroundStyle property

this.DiagramWebControl1.Model.BackgroundStyle.Type = BackgroundStyle.BackgroundType.Texture;

this.DiagramWebControl1.Model.BackgroundStyle.TextureWrapMode = System.Drawing.Drawing2D.WrapMode.Tile;

this.DiagramWebControl1.Model.BackgroundStyle.Texture = background;

}

}

VB

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Me.IsPostBack = False Then

' Create a Bitmap object for the background image

Dim path As String = Server.MapPath("/syncfusion/")

path = path + "\Web\Diagram.Web\Samples\ScriptyClient\CS\bin\suiteimage.jpg"

Dim background As System.Drawing.Bitmap = New Bitmap(path)

' Assign the image to the diagram model's BackgroundStyle property

Me.DiagramWebControl1.Model.BackgroundStyle.Type = BackgroundStyle.BackgroundType.Texture

Me.DiagramWebControl1.Model.BackgroundStyle.TextureWrapMode = System.Drawing.Drawing2D.WrapMode.Tile

Me.DiagramWebControl1.Model.BackgroundStyle.Texture = background

End If

End Sub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied