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

  • SEARCH
  • Home
  • 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 7764659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:58:08+00:00 2026-06-01T14:58:08+00:00

Update : a co-worker told me that this is a known bug in the

  • 0

Update : a co-worker told me that this is a known bug in the MVC4 beta. The issue is caused by the } bracket from the javascript causing RenderSection to think that the section has ended.

I have a rendersection in the of my layout for page specific jquery. It is not properly copying the code from my Views into the render section.

I have the following in my _Layout.cshtml (the template _Layout.cshtml + my new section)

<script src="@Url.Content("~/Scripts/AjaxLogin.js")" type="text/javascript"></script>
        @RenderSection("jqueryheader", false)

        <meta name="viewport" content="width=device-width">
    </head>

I have the following code in my Index.cshtml

@section jqueryheader {
<script type="text/javascript">
    $(document).ready(function () {
        var listid = '@(Model.ID)';
        $("#additem").load("~/Item/AddItem/" + listid);
    });
</script>
}

I get the following output in IE:

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

<script type="text/javascript">
    $(document).ready(function () {
        var listid = '9f3348ef-f713-48c6-a267-3777182cf39e';
        $("#additem").load("~/Item/AddItem/" + listid);


        <meta name="viewport" content="width=device-width">
    </head>

Anyone know why RenderSection missed the });</script>?

  • 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-06-01T14:58:10+00:00Added an answer on June 1, 2026 at 2:58 pm

    Is there a reason why you want to put your JavaScript in the header?

    I’m not 100% sure what the issue is here, but here is a best practices suggestion. I am going to advise that you put this script at the bottom of your view/page. It’s best practices. So in your layout view/master page, just before you close off your body tag do the following:

    <body>
    
         <!-- Other HTML code -->
    
         <script src="@Url.Content("~/Assets/JavaScripts/jquery-1.7.2.min.js")"></script>
         @RenderSection("JavaScriptBodySection", false)
    
    </body>
    

    And then in your view you just do this:

    @section JavaScriptBodySection
    {
         <script>
    
              $(document).ready(function () {
                   var listid = '@(Model.ID)';
                   $("#additem").load("~/Item/AddItem/" + listid);
              });
    
         </script>
    }
    

    I also have my meta tags like you because my doc type was HTML 4.01 strict. I never had this issue. I just put ALL of my JavaScript at the bottom of the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
I've got a worker thread that should wait for EDT to update the GUI
I'm trying to update a Ultragridrow cell in a background worker, but this is
Update: I thought the issue was low memory; it's not. This error happens consistently
I have a parent program that calls a worker console app when and update
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
I have a background worker that runs and looks for stuff, and when it
I am running a background worker thread that takes a long time to run.
I have a small app that a client uses to manually update some data.
I am trying to update my progressbar with the backgroundworker. Only this aint working.

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.