Solved

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

Posted on 2014-03-07
7
714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

622 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