We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to save a diagram in code behind (C#)

Thread ID:





117716 Dec 2,2014 09:40 PM UTC Dec 3,2014 12:18 PM UTC ASP.NET Web Forms 1
Tags: Diagram
Jim Jacobs
Asked On December 2, 2014 09:40 PM UTC


We have a requirement to create a diagram template programmatically - a simple diagram that will be opened later by the user.  There is no UI involved.

I have used some of the code from your online demos, but I'm at a point where I need to save the diagram.
Ideally I'd like to get a string that I can save to our database, much like I'm currently doing on the client.
Is there a diagram.save equivalent in code behind?

Here's what I have now (it should look familiar):

protected void CreateDiagramStub(String newActivityId)
        Diagram diagram = new Diagram();
        SwimLane swimlane = new SwimLane();
        swimlane.Type = "swimlane";
        swimlane.Name = "swimlane";
        Header header = new Header();
        header.Text = "Process / Activity";
        header.Height = 50;
        header.FillColor = darkColor;
        header.FontSize = 11;
        swimlane.Header = header;
        swimlane.FillColor = darkColor;
        swimlane.Orientation = "horizontal";
        swimlane.OffsetX = 350;
        swimlane.OffsetY = 290;
        swimlane.Height = 100;
        swimlane.Width = 650;
        swimlane.Lanes = CreateLanes();
        swimlane.Phases = CreatePhases();
        //String saveData = diagram.Save("myDiagram"); // What I'd like to do!

Any suggestions?



Shyam G [Syncfusion]
Replied On December 3, 2014 12:18 PM UTC

 Hi  Jim


Thanks for using Syncfusion products.


Please refer the below code snippet to retrieve the JSON string in the server side and later you can save the same string in the database. We have attached sample below


     SerializeObject serialize = new SerializeObject();

   //retrieve JSON string

     string save = serialize.SerializeToJson(DiagramContent.Model);


Please let me know if any concerns.



Shyam G

Attachment: serializesample_55218507.zip


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon