Is there a way to customize the Master Page in asp.net to resolve the Bootstrap4 dropdown issue? I am encountering an error message that says "Uncaught TypeError: Bootstrap

Hello everyone, I recently encountered an issue while trying to use dropdown in my project after updating to bootstrap 4. It was working perfectly fine before the update, but now I'm getting an error in the JavaScript. The error that pops up when I try to click the dropdown button is:

Uncaught TypeError: Bootstrap dropdown require Popper.js (https://popper.js.org)
    at Dropdown.toggle (bootstrap.js:1533)
    at HTMLButtonElement.<anonymous> (bootstrap.js:1690)
    at Function.each (jquery-3.0.0.js:359)
    at jQuery.fn.init.each (jquery-3.0.0.js:152)
    at jQuery.fn.init._jQueryInterface [as dropdown] (bootstrap.js:1675)
    at HTMLButtonElement.<anonymous> (bootstrap.js:1842)
    at HTMLDocument.dispatch (jquery-3.0.0.js:5087)
    at HTMLDocument.elemData.handle (jquery-3.0.0.js:4895)

I've tried extensively to solve this issue by including the popper.js from umd and from a direct link into the Master Page or on the same page, but to no avail.

I also attempted to change the cssClass but it didn't make any difference.

Here is a snippet from my master page (Default added by Visual Studio):

<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - Arabian Food Supplies</title>
    
    // Code continues...

</head>
<body>
    <form runat="server">
        <asp:ScriptManager runat="server" EnablePageMethods="true" EnableCdn="True">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts and references--%>
                // Additional script references...
           </Scripts>
        </asp:ScriptManager>

For my first try:

    <div class="btn-group" role="group">
        <button id="btnGroupDrop1" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action <span class="caret"></span></button>
        <ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
            <li>
                <asp:LinkButton ID="LinkButton2" runat="server">Solve</asp:LinkButton></li>
            <li>
                <asp:LinkButton ID="LinkButton3" runat="server">Abort</asp:LinkButton></li>
        </ul>
    </div>

And for my second try:

           <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
                Action<span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <li><a href="#">Solve</a></li>
                <li><a href="#">Abort</a></li>
            </ul>
        </div>

Answer №1

To easily incorporate Bootstrap 4 into your webpage, consider using a CDN or adding popper.js.

For the CDN link to Bootstrap 4, use the following code:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

For the download link to popper.js, visit https://github.com/FezVrasta/popper.js/releases

Answer №2

I have found the resolution:

To begin, open Visual Studio and navigate to

Tools > NuGet Package Manager > Manage NuGet Packages for Solution
then click on the Installed tab and uninstall AspNet.ScriptManager.bootstrab and then uninstall Bootstrap

Next Step: in the Site.Master file, within the ScriptManager tag, delete the line

<asp:ScriptReference Name="bootstrap" />

and insert the following links within the head tag of your master page

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating an ngInclude directive on the fly: A step-by-step guide

Whenever I insert this into my HTML, everything functions correctly: <div ng-include="'my-template.html'"></div> However, when attempting to dynamically create that ngInclude directive using jQuery (after the DOM has loaded), it fai ...

What is the reason behind TypeScript enclosing a class within an IIFE (Immediately Invoked Function

Behold the mighty TypeScript class: class Saluter { public static what(): string { return "Greater"; } public target: string; constructor(target: string) { this.target = target; } public salute(): string { ...

Invoke a method from a related component within the same hierarchy

Imagine this scenario: You're working on a reusable item carousel. The slide track component and the slide navigation component need to be independent and in a sibling relationship so you can position the buttons wherever you want. But how do you trig ...

transferring data to Amazon Web Services using Angular framework

I'm currently facing an issue while trying to send a file to an AWS server using an Angular dropzone. I have my AWS credentials ready, but I am unsure of how to properly make the request. Every time I attempt to drop the file into the dropzone, I kee ...

Facing the Challenge: Overcoming Concurrency Issues with Promises

In the function "myMethod" within my "gulpfile.js", I aim to generate multiple Promises based on the size of an array passed as a parameter. It is crucial for all promises to be fulfilled before proceeding with any further actions upon calling this functio ...

Prevent a form from loading depending on the response received from an ajax callback

I am currently working on implementing an ajax post function. The process involves sending data and receiving a callback from PHP with some data in return. Depending on the returned data, I need to make a decision whether to proceed or allow the user to re ...

Having trouble obtaining a GuildMember's displayName in Discord.js leads to a TypeError

I'm completely baffled by the situation here. My code is integrated within the Akairo Framework, yet the error seems to be pointing fingers at discord.js itself. Take a look at the error message below: /home/runner/guard/Listeners/automod/nicknames.js ...

Decoding the Blueprint of Easel in JavaScript

Recently, I came across a fantastic API that promises to simplify working with CANVAS by allowing easy selection and modification of individual elements within the canvas. This API is known as EaselJS, and you can find the documentation here. While I foun ...

"Identifying Mouse Inactivity in React: A Guide to Detecting When the Mouse

I need to dynamically control the visibility of a button element based on mouse movement. I am able to show the button when the mouse is moving using onMouseMove, but I'm stuck on how to hide it when the mouse stops moving. React doesn't have an ...

Enhance the readability and writability of the properties of JavaScript objects

I'm curious if there's a way to make existing properties of JavaScript objects immutable after they've been assigned. Essentially, what I want is to lock in the current properties of an object but still allow new ones to be added. Can exis ...

Extracting data from a targeted external source using PHP

Currently, I am attempting to extract data from a certain site using PHP, yet it appears that the specific information I seek is dynamically generated through Javascript or a similar technology. Any advice on how I should proceed would be greatly appreciat ...

The partial template is not functioning as anticipated

Introducing an interface designed to accept two templates, with the resulting function being a partial of one of them (similar to React-Redux): export type IState<TState, TOwnProps> = { connect: (mapStateToProps: MapStateToProps<TState, Parti ...

Order of callback execution in jQuery's ready function

When two JavaScript functions on a page need to be called once the document load is complete, is there a possibility that one function could be executed before the other, or will it always be the same order? For example, using jQuery with the following co ...

Unable to establish React API communication on cloud-based IDE for MERN Stack development

Exploring the MERN stack through this informative tutorial: https://medium.com/@beaucarnes/learn-the-mern-stack-by-building-an-exercise-tracker-mern-tutorial-59c13c1237a1 I've opted to use goorm IDE, a cloud platform similar to cloud 9 IDE. As I pro ...

React Native: Enhance the background with a vibrant stripe of color

I am trying to incorporate a strip of grey in the middle of my white background, but I am encountering an issue where I am unable to input any text inside it. Below is the code snippet I am working with: container: { flex: 1, justifyContent: "cent ...

What is the best way to substitute multiple substrings with strings from multiple interconnected arrays?

Looking for a way to manipulate a lengthy string in JS? Seeking to add new characters to each match within the string to create a fresh output? Need to handle multiple occurrences of a specific substring in the long text? Any strategies or suggestions? con ...

When a function is included in an object, it transforms into something other than a function

In my model, it looks like this: export default class UserObject { name: string; id: string; validateInsert() { } } If I interact with the model in this way: const modelUser: UserModel = new UserModel(); modelUser.ID = 1; modelUser ...

Tips for altering objects within an array

I am dealing with an array of objects that looks like this: const items = [ {name: 'Sam', amount: '455gbjsdbf394545', role: 'admin'}, {name: 'Jane', amount: 'iwhru84252nkjnsf', role: 'user'}, ...

Tips for personalizing the color scheme of Material UI Stepper Step?

I need help customizing the disabled Step color for Material UI Steppers. The default colors are Blue for enabled steps and Grey for disabled steps, but I want to change it to a different color as shown in this example: https://i.stack.imgur.com/HGGxp.png ...

"In Vim, learning how to create block comments is an essential skill to

I am seeking a way to streamline the process of generating block comments for documentation in vim. For example: /** * comment */ Are there any available plugins that can assist with this task? ...