Java scripts not working in content page of a master page in ASP.NET

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" 
    AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" 
    Inherits="ProductD.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
     <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="container mt-5 product-container">
        <h3 class="mt-4">About this item</h3>
        <button class="btn btn-link" data-toggle="collapse" data-target="#featuresCollapse" aria-expanded="false" aria-controls="featuresCollapse" runat="server">
        Features
        </button>
        <div class="collapse" id="featuresCollapse" runat="server">
            <ul class="feature-list" id="featuresList" runat="server">
                <asp:Repeater ID="Repeater1" runat="server">
                    <ItemTemplate>
                        <li><%# Container.DataItem.ToString() %></li>
                    </ItemTemplate>
                </asp:Repeater>
            </ul>
        </div>
   </div>
</asp:Content>

First thing when the code is done everything is working, but when I connected the content page with the master page the script stopped working but the bootstrap is working fine. I don’t know what to do.

  • Welcome to StackOverflow: if you post code, XML or data samples, please highlight those lines in the text editor and click on the “code samples” button ( { } ) on the editor toolbar to nicely format and syntax highlight it!

    – 

  • Your bootstrap javascript code won’t work because you have the wrong @popperjs/core version. Use @popperjs/[email protected]. This is not a content page master page issue. @popperjs/[email protected] is for bootstrap 5

    – 




  • When using a Master Page, the ID of Controls changes. Maybe that is the issue?

    – 




Leave a Comment