Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda