Click here to Skip to main content
15,919,336 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
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

<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);
        LineContext.save();
    }
</script>

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
Comments
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?
Sergey Alexandrovich Kryukov 6-May-13 2:17am    
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.
—SA

1 solution

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
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900