Closing bootstrap modal from asp.net code-behind

2

I found this answer, but get the following error:

script:

<script type="text/javascript">
    function Closepopup() {
        debugger;
        $('#myModal').modal('close');
    }
</script>

code-behind:

    ScriptManager.RegisterStartupScript(Me, Me.GetType, "Close Modal Popup", "Closepopup();", True)

error:

Unhandled exception at line 6, column 13594 in http://localhost:1230/Scripts/bootstrap.min.js

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'close'

Any ideas appreciated!

javascript
asp.net
twitter-bootstrap
asked on Stack Overflow May 30, 2015 by Ivan Pelly

2 Answers

2

modal('toggle') instead of modal(toggle)

$(function () {
   $('#modal').modal('toggle');
});
answered on Stack Overflow Feb 20, 2017 by Kadir Demirel • edited Feb 20, 2017 by FelixSFD
-1

Try $('#myModal').modal('hide'); instead of $('#myModal').modal('close');

source: http://getbootstrap.com/javascript/#modals-events

answered on Stack Overflow Jul 11, 2016 by Hugo Chavero • edited Jul 11, 2016 by lorond

User contributions licensed under CC BY-SA 3.0