2017-04-26 1 views
0

상위 페이지에서 포스트 백을 수행 할 때 Iframe의 웹 페이지를 다시로드하지 못하게하려면 어떻게해야합니까? 다음은 간단한 .aspx 페이지입니다. 포스트 백을 수행하는 Button1을 클릭하면 소스로 blank.aspx가있는 iframe이 다시로드됩니다. 어떻게 이런 일이 일어나지 않도록 할 수 있습니까? 코드는 다음과 같습니다.iframe의 웹 페이지를 다시로드하지 않고 다시 게시하기

 <div> 
     This is an empty page with a button to open a modal window in an iframe 
     <asp:Button ID="Button1" runat="server" Text="Postback" OnClick="Button1_Click" /> 
    &nbsp;<asp:Label ID="lblPostback" runat="server" Text="Initial Load"></asp:Label> 
       <!-- Trigger/Open The Modal --> 
<button id="myBtn" type="button">Open Modal</button> 

<!-- The Modal --> 
<div id="myModal" class="modal"> 

    <!-- Modal content --> 
    <div class="modal-content"> 
    <span class="close">&times;</span> 
    <p>Some text in the Modal..</p> 
     <iframe src="Site/Public/blank.aspx"></iframe> 
    </div> 

</div> 
     <script> 
     // Get the modal 
     var modal = document.getElementById('myModal'); 

     // Get the button that opens the modal 
     var btn = document.getElementById("myBtn"); 

     // Get the <span> element that closes the modal 
     var span = document.getElementsByClassName("close")[0]; 

     // When the user clicks on the button, open the modal 
     btn.onclick = function() { 
      modal.style.display = "block"; 
     } 

     // When the user clicks on <span> (x), close the modal 
     span.onclick = function() { 
      modal.style.display = "none"; 
     } 

     //When the user clicks anywhere outside of the modal, close it 
     window.onclick = function (event) { 
      if (event.target == modal) { 
       modal.style.display = "none"; 
      } 
     } 
    </script> 
    </div> 

답변

0

UpdatePanel에서 포스트 백 중에 변경 될 요소를 래핑 할 수 있습니다. iframe을 제공하면 UpdatePanel 외부에 있으므로 게시 할 때 다시로드하면 안됩니다.

+0

감사합니다. – enski

관련 문제