Pergunta

My site is written in C# with ASP.NET, all pages being loaded are .aspx pages.

I'm using a button

<input type="button" onclick="FindBuilding()">

to trigger a javascript function

function FindBuilding() {
$('#BuildingPopup).load('./BuildingPopup.aspx?lid=xxx');
$('#BuildingPopup).dialog('open');
}

that opens a modal dialog I've created

$("#BuildingPopup").dialog({
    modal: false,
    autoOpen: false,
    position: "center",
    resizable: false,
    height: 671,
    width: 1042,
    stack: true
});

The dialog is created inside $(document).ready function

The Problem:

After the dialog loads BuildingPopup.aspx the parent page then loads the same page -- this happens anytime I try to load any page in a modal dialog, regardless of content. BuildingPopup.aspx is just an example.

What I have tried to fix it:

I have tried creating the dialog first, then loading the page using the open button. I have also tried using an iframe which works but the pages never display well and it's a hassle/bad fix.

Some clues?

  • Some of the pages are calling a web service through AJAX during page load
  • The problem persists on pages with and without updatepanels
  • Some pages are evaluating code blocks during page load

UPDATE

I have discovered that the problem occurs when an updatepanel on the parent page updates.

<asp:UpdatePanel ID="updatepanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">

This occurs when an <asp:Timer> executes an OnTick() method in the codebehind(to update the panel).

Foi útil?

Solução 2

Tuns out I just needed to phrase my question better -- I finally found someone else who was having the same problem as me.

Answer was found here: UpdatePanel within jQuery.load()-ed content breaks out of the page on postback

In a nutshell the problem was that using .load was pulling in extra tags from the loaded page that was breaking the HTML on the parent page. <head> <title> etc were being pulled into the parent page and causing the problems.

To fix the problem all that was needed was to specify what content I wanted to pull from the loaded page using .load(/loadedpage.aspx #content) instead of pulling the whole page.

Outras dicas

Hmmm I had the same problem as this, and I solved it by using update panels for any code that required a callback, not sure why that would not work...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top