2

How to capture the active screen in ASP.Net MVC?

Is there any feature in JQuery for this?

What I am looking for is to save the specific part of screen (say a parent div content) on click of a button and show Print dialog to user which will print this as an image.

I found many posts around but I am looking for MVC & JQuery specific solution.

Can anybody please suggest?

Vishal Suthar
  • 17,013
  • 3
  • 59
  • 105
Anil Soman
  • 2,443
  • 7
  • 40
  • 64

1 Answers1

1

If it's a screen capture in a rendered page you might want to check out the HTML5 canvas element and capture what's drawn in there: https://stackoverflow.com/a/6887206/90011.

Put this in the view:

<canvas id="graph" width="200" height="150"></canvas>

Javascript part:

// Send the drawn image to the server
$('#sendBtn').live('click', function () {
    var image = graph[0].toDataURL("image/png");
    image = image.replace('data:image/png;base64,', '');

    $.ajax({
        type: 'POST',
        url: '/Default.aspx/UploadImage',
        data: '{ "imageData" : "' + image + '" }',
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (msg) {
            alert('Image sent!');
        }
    });
});

Source code was taken from this blog article: Send Canvas Content to Your Server

Community
  • 1
  • 1
Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61