Click here to Skip to main content
13,400,969 members (41,650 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Create a MVC 4 web application and in home page  (Index.cshtml) add
Under this line
Under <h3>We suggest the following</h3>
Add this line
<canvas id="HelloCanvas" style="float: left" > </canvas>

Under this declaration
    ViewBag.Title = "Home Page";
Now add this script

    window.onload = function () {
       var LineContext = $('#HelloCanvas')[0].getContext('2d');
        LineContext.font = "20pt Calibri";
        LineContext.fillStyle = "#024F8C";
        LineContext.textAlign = "left";
        LineContext.textBaseline = "middle";
        LineContext.fillText("Hello world", 0, 10);;

Run this application and you will see "Hello world"  Text.
Now refresh this page from address bar and you will get exception. I spent whole day but no success. Any help will be very much appreciated.
Posted 1-Jan-13 23:22pm
Christian Graus 2-Jan-13 4:27am
I don't get the question. This is a non page. It does nothing. What is the exception ? What do you want to do here ? What is your issue ?
Sampath Kumar Sathiya 2-Jan-13 6:36am
I have tried the same, but it is working fine for me. Could you please let me know what error you are getting?
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I apologized if the question is not clear.
This application works fine and only have problem when we refresh the page.

It is simple I am getting exception when I refresh the page and exception is in JavaScript at
var LineContext = $('#HelloCanvas')[0].getContext('2d');
when we try to call getContext 2nd time. It works fine first time. I build in debug and release mode. Both cases I get the exception.
Again this application works fine. Only get exception when we refresh the page.
Thank you for prompt reply.

Best regards
Agha Khan
Zoltán Zörgő 2-Jan-13 15:23pm
Please, don't add clarification as answer, since it is not. Use "Improve question" link and update the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180218.2 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100