Click here to Skip to main content
15,846,091 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys,

I've just created a new ASP.NET MVC application within Visual Studio 2013. But, I ammediately run into problems. When I try to use jQuery, i get the "JavaScript runtime error: '$' is undefined" error.

I didn't modify anything. The only thing I added was:

<pre lang="HTML">

This is the body part of my layout file

    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                @Html.ActionLink("Application name", "Index", "Home", null, new { @class = "navbar-brand" })
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
    <div class="container body-content">
        <hr />
            <p>© @DateTime.Now.Year - My ASP.NET Application</p>

    @RenderSection("scripts", required: false)

I've got the bundels in the "BundleConfig.cs" and I've got the jquery file's like "jquery-1.10.2.js" in the scripts folder. Which is all generated when created an ASP.NET MVC project.

Can anyone tell me what's wrong here?

Many thanks in advance!
Richard C Bishop 27-Feb-14 15:37pm    
Post the HTML that shows you referencing your jQuery files. There could be an order issue.

1 solution

Fixed it...

The jquery bundle had to be in the head not at the bottom of the body...

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
Share this answer
Richard C Bishop 28-Feb-14 15:29pm    
Good work!
[no name] 16-Jan-19 8:11am    
I have it in Head only. But i am getting this error
"Cannot perform runtime binding on a null reference"

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