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.
Unfortunately, activation email could not send to your email. Please try again.

How to save and load diagram from Database?

Diagram can be saved and loaded back from database.

  1. Save method of diagram returns a serialized JSON object that contain the current state of the diagram.
  2. You can convert the JSON object into a string and it can be stored anywhere (file, database, etc...)
  3. This string can be converted back to JSON object and loaded using Load method.
  4. The same methodology can be used for both ASP.NET and ASP.NET MVC application.

The following section explains you on how to implement the above.

ASP.NET MVC

In ASP.NET MVC, save and load in database is performed using AJAX Post method. The following code illustrates how to save the diagram in database.

Save

CSHTML

The following HttpPost is executed when the jQuery AJAX call is made from client side. This method accepts the JSON string from client side and it is inserted in the database.

CONTROLLER

The following code illustrates how to load the diagram from the database.

Load

CSHTML

The following HttpPost is executed when the jQuery AJAX call is made from client side. This method retrieves the JSON string from the database and send to client side.

CONTROLLER

 

Here is the sample of ASP.NET MVC

Sample:http://www.syncfusion.com/downloads/support/forum/121121/ze/saveloadsample1583379421

 

ASP.NET

In ASP.NET, save and load in database is performed using AJAX PageMethods. PageMethods is a new mechanism in ASP.NET applications where the server code can be bound to ASP.NET pages. It is an easy way to communicate asynchronously with the server using ASP.NET AJAX technologies. It is an alternate to calling the page that is reliable and carries a low risk. It is basically used to expose the web methods to the client script. 

Set EnablePageMethods=”true” in ScriptManger tag that allows to call a web page method directly from JavaScript.

ASPX

The following code illustrates how to save the diagram in database.

Save

ASPX

The following WebMethod is executed when the AJAX PageMethods call is made from client side. This method accepts the JSON string from client side and it is inserted in the database.

ASPX.CS

The following code illustrates how to load the diagram from the database.

ASPX

The following HttpPost is executed when the AJAX PageMethods call is made from client side. This method retrieves the JSON string from the database and send to client side.

ASPX.CS

 

Here is the sample of ASP.NET

Sample:http://www.syncfusion.com/downloads/support/directtrac/152798/ze/Iandbsample-1867133503

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3050 12/17/2014 03/14/2016 ASP.NET Web Forms Diagram 4.5.1
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.