question

AlenaKarle-0724 avatar image
0 Votes"
AlenaKarle-0724 asked ZhiLv-MSFT commented

Draw lines in Asp.NET from XML - what is better Javascript or System.Drawing

Hello,

I would like to create Web-App using Asp.NET, where some lines will be created using XML-Data. After each click from end-user about 90-100 lines will be displayed.

What approach is better in this case? Javascript or System.Drawing? What does lead to less bugs?

Thank you in advance

dotnet-aspnet-core-mvcdotnet-aspnet-mvcdotnet-aspnet-webpages
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The System.Drawing namespace has some limitations for certain operating systems and application types, you can check it: System.Drawing Namespace.

In my opinion, I prefer to use JQuery to call the API/Web service and get the data from the XML, and then use a JQuery plugin or the client side chart package to render the line chart.

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

With the server version, the ui is harder.

Using system.drawing means the server creates a img file and returns. The page will have a img ref. This will either be a separate request, which requires the server keep track of the previous drawing or use hidden field and return a data url ( which will increase download size)

You will also need to tell the server to regenerate the image on click. You can make an img button, and on postback the browser will send the coordinates. Or You can use JavaScript to send the click coordinates to the server via the query string of the img, or use Ajax to get the img as a dataurl.

You will also need a way for the server to keep track of the current image. You could cache and use a unique id

 <img id=“theImage” href=“/getimage?id=someid&x=&y=“>

With JavaScript you will need a graphics library.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.