Issue with loading Bootstrap modal correctly

I am currently developing a website using ASP.NET (Framework 4.0).

The Master page includes all the necessary Bootstrap and jQuery files, as shown below.

<link href="../assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="../Styles/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="../Styles/js/bootstrap.min.js" type="text/javascript"></script>

However, I have encountered an issue where the Bootstrap modal does not work properly when clicking on a button.

https://i.sstatic.net/XPQ30.png

The functionality should be triggered on a button click within a child page.

Below is the code snippet from the child page, page1.aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
{
   lblModal2.Text = "Please Add Item To Cart";
   ScriptManager.RegisterStartupScript(Page, Page.GetType(), "warning","$('#warning').modal();", true);
}

Here is the Bootstrap modal code in the child page (page1.aspx):

<div class="modal fade" id="warning" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header modal-header-warning">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×</button>
                    <h1>
                        <i class="fa fa-exclamation-triangle"></i>Warning
                    </h1>
                </div>
                <div class="modal-body">
                    <asp:Label ID="lblModal2" runat="server" Text=""></asp:Label>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">
                        Close</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

Answer №1

Simply insert the following line of code into your css stylesheet.

.modal-background {
  z-index: -1;
}

Answer №2

Delete the line of code $('#warning').appendTo("show") and instead use

$('#warning').appendTo("body");

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

How can I access a component variable within the styles in Angular?

Is it possible to utilize a variable width in my Angular 5 component template? I would like to achieve something similar to this: <style> input:checked + .slider:before { transform: translateX({{width}}px); } </style> The &apo ...

Encountering an issue while implementing a fresh design using Material-UI Version 5 and React Version 18.01 - Specifically facing problems with the '@mui/styles' package

Hi there! I am currently working with react V.18.01 and Material-ui v.5 for my application development, but encountered an error that I need assistance with. Being a beginner developer, I would greatly appreciate a code review to help me understand the iss ...

Effortlessly adjust the top margin of the div element

I have been attempting to smoothly move a div (circle), but I'm facing difficulties. The div instantly jumps to the final position instead of moving smoothly. In an effort to simulate the process of a ball falling, I tried using the animate method wi ...

Saving the previous component's DOM in a React application

Understanding the Root.js File const Root = () => ( <HashRouter> <div> <Route exact path="/" component={Main}/> <Route path="/main/:page" component={Main}/> <Route path="/detail ...

This jQuery ajax request is returning a readyState of 1 or an incorrect data type

I am currently troubleshooting an issue with the ajax response in my Wordpress plugin script. Whenever I try to retrieve a json file using jQuery.ajax, I receive {readyState: 1} as the result. Even when setting async: false, the response is always plain te ...

EaselJS - Utilizing multiple canvases with varying frame rates

Currently, I am exploring EaselJS by creating two animation instances using sprite sheets on two separate canvases positioned at different locations but with the same z-index. The issue I am facing is that these instances are not layered properly. My setup ...

Creating dynamic menus in ASP.NET using SQL database to improve user experience

I'm curious about the process for creating a role-based menu using a sitemap and a SQL Server database. What are the necessary steps? ...

The Javascript alert is displaying twice in Internet Explorer

My file validation function is set up to only allow the uploading of xls files, and it works properly by displaying an error message if a non-Excel file is uploaded. However, there is an issue with the alert firing twice in IE. Here is my code: function ...

Is add1 missing from the DOM? Learn how to include it

Having an issue with Java-Script and an HTML form. The scenario is that there's a main form with an "Add" button, which when clicked should display a second form. Next to the second form is another button labeled "Add1," which ideally should trigger ...

Rendering data in React using the array indexRendering data in React

I'm encountering an issue in React JS where I need to display all data from a REST API with a numeric index. REST API: [ { "id": "1", "start_date": "2020-05-08 09:45:00", "end_date": "2020-05-08 10:00:00", "full_name": "mirza", "cust_full_name": "fu ...

Using jQuery and regular expressions to properly escape HTML characters and reverse the process

I've encountered an issue with my HTML code that requires escaping and then converting back. Here's the code I have so far: var entityMap = { "&": "&amp;", "<": "&lt;", ...

Storing the model using three.js

Is it feasible to store models created in three.js into a database and later retrieve them, rather than just using the save tab? ...

Is there a way for me to effectively utilize the data from a successful

This is a form validation checker. I'm looking to incorporate an ajax success message feature. After all validations are complete, I would like to display a success message such as "You have successfully signed up". jQuery(function ($) { $(' ...

What is the process for showing a duplicate image in a dialog box once it has been selected on an HTML page?

I am experiencing an issue where the dialog box is displaying when I use the button tag, but not when I use the image tag. Can someone please assist? <img src='image.png' height='200px' widht='200px' id='1'> ...

Arranging elements on a website using CSS styling

I'm interested in creating a button <Button id="Button" text="Hey" />. I would like to know how I can position it on a webpage exactly where I want it, rather than it just appearing randomly without content. ...

The Full Screen Button on Google Maps isn't functioning properly in a third-party mapping application

Below you will see the '+' icon which is also supposed to function as the full screen button. https://i.stack.imgur.com/IMvHa.png However, when clicked on, it does not expand to full screen as intended. I have attempted using some basic jQuery ...

Issue with Javascript object arises when 'i' is altered

I have developed a program to highlight all words on a page that are searched for. It works well when implemented as follows: var high = "<span class='highlighted'>hello</span>"; document.getElementById("inputText").innerHTML = input ...

Strategies for dynamically incorporating customized text with unique ID attributes using jQuery while ensuring accuracy

I have a variety of divs structured like this: <div class="textwidget"><div> <div class="textwidget"><div> <div class="textwidget"><div> Here is the desired output for the divs: <div class="textwidget" id="widget-1 ...

Is it possible to eliminate jagged edges in CSS 2D rasterization by applying anti-aliasing to subpixels?

It appears that the HTML/CSS engine automatically rounds values to the nearest whole px unit. It would be interesting to see non-discrete sizing options (floats). A closer look reveals that in Chrome, widths/heights are rounded to the nearest physical pix ...

Delete unnecessary css code

After years of working on a website, it has grown significantly in size. The CSS files have become quite messy and unclear. I need to figure out how to identify which parts of my extensive CSS file are not being utilized on my homepage so that I can safel ...