show image in percentage sized canvas HTML5/JS/ASP.NET MVC/CSS
<p>I have to "fix" a ASP.NET MVC 5 Website. Gridlayout is done with bootstrap.
The Problem is, there is a Canvas, that should fill a "50% width" div. 
When I set the width of the Canvas to 100% that works great.
In the canvas i want to show an Image I got from an Controller. To show it in the right resolution i need to set the height of the Canvas, but first I need to know how many Pixels I got in X-Dimension, to scale the image. 
Is there any nice way to do so? I tried </p>

<pre><code>parentDiv.innerWidth()
canvas.clientWidth
canvas.style.width
parentDiv.clientWidth
</code></pre>

<p>Most of them returned zero. </p>

<p>It needs to be an canvas, where I show the image, because I want to draw something in the image. </p>

<p>Any idea?</p>

<p>Thanks</p>

<p>EDIT:</p>

<p>Is there a "good" way to show an image in a canvas, that is sized in percent?</p>