kiran n kiran n - 1 year ago 84
Javascript Question

Display a Modal Popup window

Here I am trying to display a modal popup window by using button click event.

This is Modal popup division

<div id="myModalPopup" class="modal fade" role="dialog" data-keyboard="false">//Modal popup
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="background-color: orangered; border-top-left-radius: 4px; border-top-right-radius: 4px;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Company Details</h4>
<div class="modal-body">
<asp:Panel ID="Panel2" runat="server" class="tab-pane">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-4">
<asp:Label runat="server" ID="lblNmeComp" Text="Name of Company" AssociatedControlID="txtNmeComp" CssClass="control-label" />
<asp:TextBox runat="server" ID="txtNmeComp" CssClass="form-control" />
<br />
<div class="col-sm-4">
<asp:Label runat="server" ID="lblAdrComp" Text="Address of Company" AssociatedControlID="txtAdrComp" CssClass="control-label" />
<asp:TextBox runat="server" ID="txtAdrComp" CssClass="form-control" />
<br />

This is My button code

<button id="AddMore_Button" class="btn btn-primary" data-target="myModalPopup">Add More</button> //button for Add more

This is My Jquery.

<script type="text/javascript">
$(document).ready(function () {

// Attach Button click event listener
$("#AddMore_Button").click(function () {
// alert('a');

Here when I click button it's not displaying anything, then refreshing and going to first screen. If I put alert() it fires and after pressing OK same thing happening.

Answer Source

Try this to show the modal

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download