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

Alena Karle 1 Reputation point
2022-05-28T08:55:59.547+00:00

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

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,207 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,288 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,931 Reputation points
    2022-05-28T16:33:06.74+00:00

    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.

    0 comments No comments