Executing Click and Clientclick events with Bootstrap Modal - A guide

Here's the Markup I'm Using :

Note: Currently, I am utilizing the Metronic pre-built template that comes with all necessary components.

<link href="vendors.bundle.css" rel="stylesheet" type="text/css">
    <link href="style.bundle.css" rel="stylesheet" type="text/css">
    <script src="jquery.min.js" type="text/javascript"></script>
    <script src="scripts.bundle.js" type="text/javascript"></script>
    <script src="vendors.bundle.js" type="text/javascript"></script>
    <script src="bootstrap-datepicker.js" type="text/javascript"></script>

<script>
        $(function () {

            $('#trigger').click(function () {
                $('#myModal').modal("toggle");
                return false;
            })

        });
    </script>

Displayed below is my code:

<asp:Button runat="server" ID="trigger" OnClick="Unnamed_Click" Text="Click"/>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" style="display: none;" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
<div class="modal-header">
    <h5 class="modal-title" id="exampleModalLabel">Bootstrap Date Picker Examples</h5>
    <asp:Label runat="server" ID="ShowLbl"></asp:Label>
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true" class="la la-remove"></span>
    </button>
</div>
<div class="modal-body">
    <div class="form-group m-form__group row m--margin-top-20">
        <label class="col-form-label col-lg-3 col-sm-12">Minimum Setup</label>
        <div class="col-lg-9 col-md-9 col-sm-12">
<input type="text" class="form-control" id="m_datepicker_1_modal" readonly="" placeholder="Select date">
        </div>
    </div>
    <div class="form-group m-form__group row">
        <label class="col-form-label col-lg-3 col-sm-12">Input Group Setup</label>
        <div class="col-lg-9 col-md-9 col-sm-12">
<div class="input-group date">
    <input type="text" class="form-control m-input" readonly="" placeholder="Select date" id="m_datepicker_2_modal">
    <div class="input-group-append">
        <span class="input-group-text">
<i class="la la-calendar-check-o"></i>
        </span>
    </div>
</div>
        </div>
    </div>
    <div class="form-group m-form__group row m--margin-bottom-20">
        <label class="col-form-label col-lg-3 col-sm-12">Enable Helper Buttons</label>
        <div class="col-lg-9 col-md-9 col-sm-12">
<div class="input-group date">
    <input type="text" class="form-control m-input" value="05/20/2017" id="m_datepicker_3_modal">
    <div class="input-group-append">
        <span class="input-group-text">
<i class="la la-calendar"></i>
        </span>
    </div>
</div>
<span class="m-form__help">Enable clear and today helper buttons</span>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-brand m-btn" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-secondary m-btn">Submit</button>
</div>
        </div>
    </div>
</div>

Upon loading the modal, the clientclick event is triggered.

I also want to trigger the onclick event accordingly. Is it feasible? Seeking assistance as I am new to this. Please advise if there is a way to achieve this.

Below is the back-end :

protected void Unnamed_Click(object sender, EventArgs e)
{
   //ShowLbl.Text = "Clicked";
    do some SQL Work ();
    then show it to modal();
 }

Answer №1

Programming in C#:

protected void Unnamed_Click(object sender, EventArgs e)
{
    myModal.Visible = true;
   //ShowLbl.Text = "Clicked";
    execute some SQL queries ();
    then display the result on a modal popup();
 }

HTML Code:

<div runat="server" Visible="False" class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" style="display: none;" aria-hidden="true;">

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

Unable to execute controller due to service call testing failure

I'm currently working on writing a code to test the service call in my controller. The goal is to unit test a specific function within the controller that makes the service call and retrieves data. While I am using local JSON for testing purposes, the ...

protecting my information without relying on https

I have created a public-facing website using ASP.NET MVC-5 web application. The website is now live and public, so it does not require https. However, there is a Contact Us form on the site where users provide their name, email, and/or telephone number. ...

Closing the React Material UI drawer with nested list items upon clickingORClicking on nested list

Currently, I am encountering an issue with my React project that utilizes Material-UI. The problem arises when I incorporate nested list items within the drawer component. Previously, everything was functioning smoothly until the addition of these nested i ...

Can someone guide me on how to use contract.on() in ethers.js to listen to events from a smart contract in a node.js application?

I've been working on a node.js application using ethers.js to listen to events emitted from the USDT contract Transfer function. However, when I run the script, it exits quickly without displaying the event logs as expected. I'm unsure of what st ...

Issue with Auth0 not properly redirecting to the designated URL in a React application

auth.js import auth0 from 'auth0-js'; export default class Auth { constructor() { this.auth0 = new auth0.WebAuth({ domain: '<properURL>', clientID: '<properID>', re ...

The radio input is not being properly checked using ng-checked in Angular

The ng-checked attribute is causing issues in the application, specifically with radio buttons. It seems to be working fine for checkboxes but not for radio buttons. <input type="radio" class="radio" name="job_class_radio" ng-checked="key===jobClassDat ...

Strategies for aligning tooltips with the locations of dragged elements

One of my projects involves a simple drag element example inspired by Angular documentation. The example features a button that can be dragged around within a container and comes with a tooltip. <div class="example-boundary"> <div ...

I am unable to eliminate the parentheses from the URL

I am in need of creating a function that can extract the content inside "()"" from a URL: Despite my efforts, the function I attempted to use did not provide the desired result. Instead of removing the "()" as intended, it encoded the URL into this format ...

Trouble encountered while setting up Firebase Auth for React Native by utilizing AsyncStorage

Trying to implement SMS authentication via Firebase has presented some challenges for me. Despite poring over the documentation and scouring Google for solutions, I've hit a dead end. My setup is pretty basic - just a single input field and a "Send" b ...

Tips for effectively utilizing tags in AngularJS search functionality

I attempted to implement a search box that utilizes tags, shown in the image below. Despite trying to use bootstrap tags, it did not work as intended. Here is a visual representation of how the search should be displayed: https://i.sstatic.net/COqai.png ...

What techniques can I implement to optimize the speed of this feature in JavaScript?

I have developed a feature that highlights any text within a <p> tag in red based on a user-specified keyword. The current implementation works well, but it is slow when dealing with over 1000 lines of <p>. Is there a faster way to achieve this ...

The Right-Click Functionality in SlickGrid

Incorporating SlickGrid into my web application, I am currently contemplating whether to display the context menu based on the specific data row that is right-clicked. However, I am experiencing difficulty in triggering a right-click event as opposed to ...

Guide on embedding a map inside a popover using Bootstrap

I am trying to create a popover that displays a map inside it. I attempted this simple example: <!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" c ...

What is causing my radio button event to activate when a separate radio button is selected?

I have implemented the code below to display "pers" and hide "bus," and vice versa. JQuery: $('input[name="perorbus"]').click(function() { if ($(this).attr('id') == 'bus') { $('#showbus&apo ...

Experiencing an issue with AJAX or HTML on Mozilla Firefox?

This website was developed using the asp.net platform with Ajax enabled. Although it functions perfectly on Internet Explorer and Chrome, it seems to be encountering issues on Mozilla Firefox. The arrows are working fine, but the numbers are not appearing. ...

How to iterate through two objects simultaneously using a directive in Angular and Vue.js

I am facing a challenge with creating an Angular directive that can iterate over a data object and display its values along with the values of a second unrelated object with similar structure. Currently, I am developing a translation app where the origina ...

Discover the technique for splitting a string using jQuery with multiple strings as separators

I am looking to split a string in jQuery or JavaScript using multiple separators. When we have one string as a separator, our code looks like this: var x = "Name: John Doe\nAge: 30\nBirth Date: 12/12/1981"; var pieces = x.split("\n"), p ...

Transform JSON into a C# array, with property name determining its index

Is there a preferred method for deserializing the JSON provided below? { "i": 5 "b0": "ABC", "b1": "DEF", "b2": "GHI", "s0": "SABC", "s1": "SDEF", "s2": "SGHI", } I am looking to convert it into a C# class with a structure similar to this: ...

Controlling the activation of a button on a parent modal popup from a child within an IFrame using javascript

I am struggling to toggle the button on the main window from the child window. Here is a snippet from the main page: <ajaxToolkit:ModalPopupExtender ID="mpeTest" runat="server" CancelControlID="btnClose" PopupControlID="pnl1" TargetControlID="showMp ...

Troubleshooting Angular JS Module Injection Issues

Lately, I've been exploring the wonders of angular JS and it has truly impressed me. However, one concept that still eludes my full understanding is injection. Despite this, I have successfully employed this technique across numerous pages in my proje ...