I want to show a modal window that is the response to an UPDATE to the DB of successful operation, I am defining the modal window in a Response.Write
but it does not show me the window, I already loaded the jquery libraries, bootstrap but still it does not show me anything
Response.Write(" <div class='modal fade' id='modal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" & _
" <div class='modal-dialog'>" & _
" <div class='modal-content'>" & _
" <div class='modal-header'>" & _
" <button type='button' data-dismiss='modal' aria-hidden='true'>x</button>" & _
" <div class='modal-body'>" & _
" <blockquote>" & _
" <p style='text-align:justify;'>Registro exitoso<span id='error2'></span></p>" & _
" </blockquote> " & _
" </div>" & _
" <div class='modal-footer'>" & _
" <a href='reporte_renov' data-dismiss='modal' class='btn btn-danger btnsalir'>Aceptar</a>" & _
" </div>" & _
" </div>" & _
" </div>" & _
"</div>")
*when I remove the class="modal fade" if it shows me the window like this: Am I missing something to show it properly?
This happens because by default the modals in Bootstrap are hidden (they have them
display:none
in the class.modal
). So it's not enough to just write the modal in HTML, you also have to activate it for it to be displayed.Once you've written your modal in code, you can show it programmatically using the
modal()
JavaScript command:Thus, when confirmation is received that the UPDATE was successful in the database and you write the modal on the page, you must then open it with
$("#modal").modal()
(because the ID is "modal") so that it is displayed on the screen.Here is an example of how it works. Click on the button so that the modal opens with JavaScript
An alternative, if you just want to display a Registration Successful message, you can use this library
AlertifyJS
, you can download it here: Alertify . and display the message with a simple alert (you can use themes fromBootstrap
too):It will look like this:
Well if you want to call it in the codeBehind, you call it with
RegisterStartupScript
: