Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
jQuery only seems to be working in Layout.cshtml

I am currently working on the basics of a .NET C# Razor page application running the following:

  • Razor pages
  • .NET 5/C#
  • jQuery v3.5.1
  • Bootstrap v4.3.1

My current issue is that jQuery (and plain JS) are only working in the Layout.cshtml file, I have tried the following:

  1. Script tags in the head of _layout.cshtml
  2. Script tags at the bottom of the body of _layout.cshtml
  3. Wrapping the jQuery in @section scripts{}

At this stage I am fairly sure it is just a case of, it needs to be setup in a very particular way in .NET5, but I really have no more clues

Bottom of _Layout.cshtml

    </header>
    <div class="container-fluid">
        <main role="main" class="pb-3">
            @RenderBody()
        </main>
    </div>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>

    @RenderSection("Head", required: false);
    @RenderSection("Scripts", required: false);

</body>
</html>

Bottom of the index.cshtml file

@section scripts {
    <script>
        $(document).ready(function () {
            $(".btn-reply").click(function (event) {
                alert("it works");
            });
        });
    </script>
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Rather frustratingly this turned out not to be anything JS related at all, in actually fact this was down to main div with the class of row having a z-index of -1, no idea how this came to be, I don’t recal having set this, but if I did I whole apologise to anyone who took the time to read this.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!