Solved

How to get a handle to elements on html/aspx page using C#?

Posted on 2014-03-07
7
690 Views
Last Modified: 2014-04-08
Hello,

I'm about to design a 3 tier layer web application as:

database(sql server) <> middle tier (mvc/c#) <> front-end (js/html/css)

on a page I will be providing <canvas></canvas> so that user can sketch 2d objects using javascript. This will be a SVG sketch and I need to let user store that in a table (as xml).

My question is how can I get a handle to the canvas and what it lives on it after a sketch is done?

Thanks,
ak
0
Comment
Question by:akohan
  • 2
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39913820
Get a "handle" from where? C#, or Javascript?
0
 

Author Comment

by:akohan
ID: 39918378
from front-end part where my canvas is. Yes from JS.
0
 

Author Comment

by:akohan
ID: 39931116
Anybody has idea how this can be done?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39977796
The canvas is just an element in the page, so you can grab it like:
var canvas  = document.getElementById("Your_Canvas_Id");

Open in new window

To get the contents of the canvas as a base64 encoded value that you can save to the database, you can use the toDataURL() method of the canvas object:
var data = canvas.toDataURL();

Open in new window

0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question