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 6095253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:47:28+00:00 2026-05-23T12:47:28+00:00

I hava an editor template for, let’s say, date: @model DateTime @section AdditionalJavaScript2 {

  • 0

I hava an editor template for, let’s say, date:

@model DateTime
@section AdditionalJavaScript2
{
   /* some js code */
}

@Html.TextBox("", Model.ToString("d.M.yyyy"), new { @class = "date" }) 

Now, I would like to put some js code into the HEAD section, but this doesn’t work.

Of course, I have a this section in my layout.cshtml:

<head>
  ...
  @RenderSection("AdditionalJavaScript2", required: false)
</head>

It works from the plain view, but not from partial view (editor template).

Why?

And, is there a workaround?

Thanks,

Igor

  • 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-23T12:47:29+00:00Added an answer on May 23, 2026 at 12:47 pm

    A partial-view does not use a template, it returns “raw” html to be included in your page (by Javascript). It does not have access to anything but the stream it returns itself.

    Think of it like this: You typically call a partial view from Javascript/AJAX to get some new html. You get the return, and replace some DIV-tag. How can the system (FireFox, Chrome, …) know, that there is some extra section of data that needs to replace something in the HEAD tag.

    There are some workarounds:

    • Don’t put the script in the HEAD
    • Add a parameter switch betweed the html and the script. You need to client-side calls, one to get the html, and one for the script. You include the calls to the partial-view on two locations on your page.
    • Separate the script and the html using some pre-defined tag like <!-- SEPERATOR -->, and let the calling code split the result, and put it in the correct position.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hava a CSV file that I want to treat as source code. Essentially
I hava a form (form_remote_tag) that updates a comments section. The form is in
I hava a data window object, in which I am fetching some attributes from
I hava a java program, a section of it is compute intensive, like this
I hava a remote validator setup like so remote: { type: POST, url: /some/url,
I hava a thread in which I have an infinite loop, doing some network
I hava a jQuery UI datepicker which I intend to use with a textbox
I hava a webview showing some contents which is getting from server. Now on
I hava a url such as search.do?offset=20 offset sometimes is in the url sometimes
I am trying to upload an image to the server. I hava a form

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.