Solved

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

Posted on 2014-03-07
7
680 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

776 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