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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:17:01+00:00 2026-05-28T04:17:01+00:00

in my Layout file (I use the Razor syntax) I have included the jQuery

  • 0

in my Layout file (I use the Razor syntax) I have included the jQuery script library.

In my partialView, I have jPaginate script library and the code that generates this plugin. The problem is, in that scenario that plugin is not being rendered, but if I move the jQuery script library to the PartialView, it works. But I can’t move the jQuery script library from the Layout.

So, how to access the scripts included in the Layout page in the
PartialView ?

Or maybe there is other solution ?


the code:

Layout.cshtml

<head>
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
</head>

<body>
     @RenderBody()

     @RenderSection("Scripts", false)
</body>

MyView.cshtml

@{ Html.RenderAction("SomeAction", "MyContoller"); } //it outputs the PartialView.vshtml

    @section Scripts {
        <script src="@Url.Content("~/Scripts/jquery.paginate.js")" type="text/javascript"></script>

        <script type="text/javascript">
            $(document).ready(function () {
                $("#pages").paginate({
                    count: 12,
                    start: 1,
                    display: 10,
                    border: false,
                    text_color: '#888',
                    background_color: '#EEE',
                    text_hover_color: 'black',
                    background_hover_color: '#CFCFCF'
                });
            });
        </script>
    }

PartialView.cshtml

<link href="@Url.Content("~/Content/jpaginate.css")" rel="stylesheet" type="text/css" />

<div id="pages"></div>
  • 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-28T04:17:01+00:00Added an answer on May 28, 2026 at 4:17 am

    Where is your jQuery script rendered in the Layout? Is it towards the end of the layout? If this is the case then when you include the plugin in your partial, jQuery is not yet defined. I would recommend you defining a section in your layout towards the end that will contain custom included scripts:

    <body>
        ...
        ...
        <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
        @RenderSection("Scripts", false)
    </body>
    </html>
    

    and then in the view that is using that partial (not in the partial, a partial shouldn’t be dealing with any scripts, it should be markup only) override this section to include any plugins this view requires:

    @section Scripts {
        <script src="@Url.Content("~/Scripts/foo.js")" type="text/javascript"></script>
        <script type="text/javascript">
            // some inline script that uses the foo plugin
        </script>
    }
    

    This way all scripts that this page requires will get rendered at the end of the markup which is the recommended approach.

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

Sidebar

Related Questions

To use custom layout file in my app I'm using this following code, set
I have custom component that I can place in my layout file (XML) for
I am trying to have a partial layout file that store all the config
I have strange behavior with android.R.layout.simple_dropdown_item_1line while using MultiAutoCompleteTextView . The code I use
I have a simple activity that I use in many apps. The layout is
Is there an XML tag which I can use in a layout file that
When my Activity loads, I inflate a layout file that I use for a
I have a dialog in Android, as a layout I use this file: <?xml
I have in the layout file < script type=text/javascript> $(function() { // Datepicker $('#passExp1').datepicker({
I want to use a custom template file which shoud use the base layout

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.