Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda