Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC
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 1-Jan-13 22:22pm
AghaKhan1.5K
Comments
Christian Graus at 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 at 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 at 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

Rate this: bad
good
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
  Permalink  
Comments
Zoltán Zörgő at 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
0 Sergey Alexandrovich Kryukov 6,212
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
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