Unable to trigger confirmation modal popup when logging out in MVC

Currently, I am working on a MVC project where I have implemented the User Login session. I have added a user logout button within a Bootstrap modal popup confirmation box. However, it seems that the box is not functioning properly. Does anyone know how to fix this issue?

Thank you

<header>
  <a id="header-logo" href="#"></a>

  <a class="navbar-brand" href="#"><img src="~/img/ekinitting _logo.png" class="img-responsive" style=" position: absolute; display: block; width: 260px; height: 65px; left: 10px; top: 10px;"></a>

  @using (Html.BeginForm("LogOut", "Login", new { area = "" }, FormMethod.Post, new { id = "logoutForm" })){
    @Html.AntiForgeryToken()
    <a href="javascript:document.getElementById('logoutForm').submit()" style="  top:-28px;"><input type="image" id="myimage" src="~/img/log_out.png" style=" margin-top:15px; margin-left:150px; position:relative; float:right;  " data-toggle="modal"
       data-target="#basicModal" /></a>

  }
  <div class="col-lg-2" style="color:#ff0000; margin-top:28px; left:1055px; position:relative; ">

     @Html.ActionLink("Hello           " + ((eKnittingData.UserRegistration)Session["User"]).UserName + " :)", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Welcome", style = "color:#fada5b; text-decoration: none; font-size:14px;" })

  </div>
  <!--/.nav-collapse -->
  <a href="~/Home/Index">

    <input type="image" id="myimage" src="~/img/Red-home-icon.png" style="top:15px; position:relative; left:150px; float:right; " />

  </a>

</header>

Modal

<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  <div class="modal-dialog  modal-sm">
    <div class="modal-content" style="background-color:#ffffff; border:solid 4px #e85656;margin-top:253px; left:-25px;">
      <div class="modal-header" style="background-color:#e85656; height:15px;">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top:-12px;">x</button>
        <span class="glyphicon glyphicon-warning-sign" style=" color:yellow; font-size:large; top:-10px; left:115px;" aria-hidden="true"></span>
        <h4 class="modal-title" id="myModalLabel" style="text-align:center;"></h4>
      </div>
      <p style="text-align:center; font-family:'Ebrima'; color:black; margin-top:15px;"> <strong>  Are you sure you want to logout? </strong></p>
      <div class="modal-footer" style="text-align:center;">
        <a href="#"><button type="button" class="btn btn-success  btn-xs" style=" width:50px;">Yes</button></a>
        <button type="button" class="btn btn-danger btn-xs" data-dismiss="modal" style=" width:50px;">No</button>
      </div>
    </div>
  </div>
</div>

Answer №1

To ensure a seamless transition, make sure to place your form within the modal itself and not next to the logout button that triggers the modal.

Simply place the form in the modal-body section where you currently have the confirmation text in your code.

Remember to keep the form outside of the modal-body and footer div for optimal functionality.

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

Can one retrieve the CSS/XPath from a Capybara Element?

Is it possible to extract CSS/XPath from a Capybara Element? I have attempted to use #path but it doesn't appear to be effective. Here is the link I tried: The test is being executed on Selenium Webdriver. ...

The process of overriding CSS applied through JavaScript

I am using a third-party multi-select dropdown. Similar to Select2, the multi-select dropdown is created using JQuery with select2.min.js and the width of the dropdown is automatically calculated. Is there any way to apply static width to it, as I believe ...

HTML: Hover effect does not work for icons when hovered alongside anchor elements within a list item

I wanted to add a special effect to my navigation list items: When the mouse hovers over the anchor tags of the list items (or even in the active state), I wanted the image in the <span> to be replaced with a colored version of the image. The color o ...

Unable to achieve desired result when trying to combine styled components props with next adjacent selector

After transitioning from active classes to passing props to styled components, I encountered a minor issue. The prop passing is functioning correctly, but there seems to be an issue with the CSS. Prior to switching to props, this section worked flawlessly ...

Automatically populate login page fields with JavaScript code

I'm having trouble getting my JavaScript code to autofill credentials on a login webpage. Here's the code: Can anyone spot what I'm doing wrong? <!DOCTYPE html> <html> <body> <form id="formulario" name="formulario ...

Issues with the reset.css file preventing the desired reset from taking

I am currently using a reset.css style sheet that has the following code, HTML * { margin: 0; padding: 0; padding: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; te ...

What is the best way to include a class in this PHP file?

While working on my website using WordPress, I came across an interesting plugin that displays the total sales and views of a product. However, I am facing a challenge in customizing the field with CSS. I'm unsure about adding a class in the PHP file ...

Enhancing the appearance of a JSX component in React

I have a segment of code within my project that calculates a specific percentage and displays it on the dashboard. <text className="netProfit-circle-text" x="50%" y="50%" dy=".2em" textAnchor="middl ...

Tips for creating distinct hover descriptions for each element in an array

My dilemma may not be fully captured by the title I've chosen, but essentially, I am working with a list of names and I want each one to display a unique description when hovered over with a mouse. On the surface, this seems like a simple task, right ...

Override CSS properties / prevent inheritance

I'm currently facing a challenge in Wordpress where I need to insert a link quickly, but there are intricate styles applied to all the anchor links within a specific section. Here is a snippet of the CSS selector and styles being used: div.content-ro ...

Guide to updating the value of a CSS seconds dynamically

let timerSeconds = 10; // This value will be retrieved from a database function StartCountDownTimer() { let timerStart = new Date(); let css_seconds = `${timerSeconds}s`; const css_root = document.querySelector(':root'); let cssVa ...

Is there a way to eliminate this from the footer section?

Check out my website: If the text is not visible, try using a larger monitor or zooming out in your browser. I've added an image to help explain: I only want to remove that element + title on the first page This is the HTML code: <div id="to ...

Issue with Bootstrap 4 custom list-group collapse arrow not working as expected

I recently customized a Bootstrap 4 list-group to include collapse functionality. In my customization, I added a CSS caret arrow with the following behavior: 1. Initially pointing down 2. Clicked once, it points up 3. Clicked again, it returns to the init ...

Change the maximum width of the parent element when it is positioned relatively

In my web design project, I have a full-container with a maximum width of 1080px and positioned relatively to hold all content. Within this container, there is another div element (.portfolio) that I want to extend to the full width of the page (max-width: ...

What is the best way to integrate a bootstrap CSS stylesheet into my Express/Node.js project?

Currently, my approach involves using the following code to fetch my html file. app.get("/", function (request, response) { response.sendFile(__dirname + "/public_html/index.html"); }) The html file contains a form with method="post" and a submit button. ...

Having trouble with a basic CSS Height example, could use some assistance. Thank you in advance!

Could someone shed light on why my straightforward CSS 100% example isn't working as expected? HTML: <div id="header">header</div> <div id="nav">Nav</div> <div id="title">title</div> <div id="content"> C ...

Struggling to vertically align text beside an image in Twitter Bootstrap - any suggestions?

I'm currently incorporating Twitter Bootstrap and facing a challenge with centering text vertically next to an image that exceeds the size of the text. The use of line-height is not feasible as the text spans multiple lines and may be subject to addi ...

Aligning float:left divs vertically

I have multiple divs with equal widths but varying heights that I need to fit together tightly. When I set them to float left, they don't align vertically but instead line up at the bottom of the row above. Even with the example below, I want to eli ...

Update the font style of the navigation bar

Hey there! I recently downloaded a template from this website: . However, I'm facing an issue with the nav bar displaying strange fonts when using Vietnamese letters. For example, "Nước" shows up as all uppercase and the letters "uo" are shortened. ...

What is the most efficient way to define the font properties for all H1-H6 headings in a single declaration

Is there a way to set all font properties for H1-H6 headings in one CSS declaration? CSSLint.net is flagging multiple definitions of heading styles as an issue. I currently have specific styles for each heading level: h1 { font-size: 1.8em; margin-top: ...