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 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

I have strange behavior with android.R.layout.simple_dropdown_item_1line while using MultiAutoCompleteTextView . The code I use
When my Activity loads, I inflate a layout file that I use for a
I have an audio player toolbar activity that has a corresponding layout file. I
I want to use a custom template file which shoud use the base layout
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I'm thinking about putting a .txt file in res/drawable or in res/layout to have
I have a custom View that I'd like to specify the layout of in
I'm trying to use my layout file place rows of TextViews and Buttons. It
I'm trying to use scrollTo method of webview. This my layout file for the
If I have one layout file => res/layout/item.xml : <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

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.