Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6067695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:38:08+00:00 2026-05-23T09:38:08+00:00

I have some working Raphael-js code from this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ and I’m trying to

  • 0

I have some working Raphael-js code from this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ and I’m trying to include the working code in to an MVC3 Razor view. The javascript isn’t getting executed. I can’t seem to find the error or a good resorce which explains how to include javascript within Razor.
Here is my .cshtml where I expect the Rapheael drawing to be rendered at the canvas_container div.

@{
    ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
<p>
    To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
        http://asp.net/mvc</a>.
</p>

<div id="canvas_container">
</div>

@section JavaScript
{
    <script type="text/javascript" src="@Url.Content("~/Scripts/raphael.js")" />
    <script type="text/javascript">
        window.onload = function () {
            var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);
            var circle = paper.circle(100, 100, 80);
            for (var i = 0; i < 5; i += 1) {
                var multiplier = i * 5;
                paper.circle(250 + (2 * multiplier), 100 + multiplier, 50 - multiplier)
            }
            var rectangle = paper.rect(200, 200, 250, 100);
            var ellipse = paper.ellipse(200, 400, 100, 50);
        }
    </script>
}

And here is the rendered view where the javascript is not executed:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Home Page</title>
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>MVC Movie App</h1>
            </div>
            <div id="logindisplay">
                    [ <a href="/Account/LogOn">Log On</a> ]
            </div>
            <nav>
                <ul id="menu">
                    <li><a href="/">Home</a></li>
                    <li><a href="/Home/About">About</a></li>
                </ul>
            </nav>
        </header>
        <section id="main">
                <h2>Welcome to ASP.NET MVC!</h2>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
            http://asp.net/mvc</a>.
    </p>

    <div id="canvas_container">
    </div>
        </section>
        <footer>

        </footer>
    </div>
        <script type="text/javascript" src="/Scripts/raphael.js" />
        <script type="text/javascript">
            window.onload = function () {
                var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);
                var circle = paper.circle(100, 100, 80);
                for (var i = 0; i < 5; i += 1) {
                    var multiplier = i * 5;
                    paper.circle(250 + (2 * multiplier), 100 + multiplier, 50 - multiplier)
                }
                var rectangle = paper.rect(200, 200, 250, 100);
                var ellipse = paper.ellipse(200, 400, 100, 50);
            }
        </script>
</body>
</html>

Thanks
Scott

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:38:11+00:00Added an answer on May 23, 2026 at 9:38 am

    It’s not working because your javascript follows a self-closed script tag, which is invalid.

    You need to change

    <script type="text/javascript" src="/Scripts/raphael.js" />
    

    to

    <script type="text/javascript" src="/Scripts/raphael.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some working Javascript code that generates an RDF/XML document using variables picked
I am working in the .NET 2.0 framework. I have some code working, just
I have some code I am working on that worked just fine until I
I have some really complicated legacy code I've been working on that crashes when
On a recent project I have been working on in C#/ASP.NET I have some
I have some working code that uses IImgCtx to load images, but I can't
I have some working Javascript that manipulates the some DOM elements. The problem is,
So far, I have some working code that goes into a list of servers
Edit: solution added. Hi, I currently have some working albeit slow code. It merges
I'm new to javascript and I am looking through some Raphael demo code. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.