Solved

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

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

Expert Comment

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

Author Comment

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

Author Comment

by:akohan
Comment Utility
Anybody has idea how this can be done?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now