Search code examples
asp.nettwitter-bootstrappopupmodal-dialogwindow

How to open aspx page inside bootstrap modal popup


I have this link

<a href='' data-toggle='modal' data-target='#modalC'>Book Now</a>

And i have this code which opens a bootstrap modal popup.

            <div class="modal fade" id="modalC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Cantidad reservas mensuales</h4>
      </div>
      <div class="modal-body" id="content">

      </div>
  </div>
  </div>
  </div>

Everything appearing inside div with id content is what appears inside modal popup, so my question is is there a way to show my already created aspx webform inside the modal popup without having to copy all the html and codebehind to this div?

I've heard something about window.open but i think it is not the case, Thank you in advance.


Solution

  • You can add an iframe into the modal body and load the url of your page inside it.

    <div class="modal fade" id="modalC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">Cantidad reservas mensuales</h4>
                </div>
                <div class="modal-body" id="content">
                    <iframe src="your new page url">
                </div>
            </div>
        </div>
    </div>
    

    if you want to load the page everytime you open the modal, you can add the iframe src when you click on the button you use to open the modal (or whichever method you use to open it).