search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Modal Dialogue - on exit, refresh an underlying page

Asked by mrplatypus
6 years ago.

Hi Dan and Team,

I currently have a web form using a modal dialogue window to add an entry to a database.

The functionality is working, in that additions are made to the table; the modal form is closed.

The issue is that the underlying page/grid needs to be refreshed when the modal form is closed.

Please advise on how to refresh the page/grid once the modal dialogue is closed?

Thanks

mrplatypus

Comment posted by mrplatypus
6 years ago.

Quick addition: I am currently using daypilot 8.2.3519.0

Answer posted by Dan Letecky [DayPilot]
6 years ago.

You can reload the page by calling document.location.reload() in the onClosed event handler:

var modal = new DayPilot.Modal({
  onClosed: function(args) {
    // ...
    document.location.reload();
  },
  // ...
});
modal.showUrl("Edit.aspx");

If you place the grid inside an UpdatePanel you can refresh it by reloading the UpdatePanel:
https://stackoverflow.com/questions/3490457/update-an-updatepanel-manually-using-javascript-or-jquery

Comment posted by mrplatypus
6 years ago.

Dan & Team,

I've added the code as described.
When a user clicks off of the modal form, the onClosed event fires.

I have used:

Modal.Close();
Modal.Close(this);
Modal.Close(this, "OK");

to close the form - none of which work?

Hope you can help?

Comment posted by Dan Letecky [DayPilot]
6 years ago.

1. Just to make sure - please check that you are using the latest version of DayPilot.Modal from here (2.7):
https://code.daypilot.org/81367/daypilot-modal

2. The Modal.Close() method defined in Daypilot.Modal-2.7.cs/Daypilot.Modal-2.7.vb can be called on the server side from the modal content page to close the dialog. It's not possible to close the modal on the server side from the parent page.

3. If you want to close the modal using JavaScript:

If you have the modal instance reference ("modal") you can call .close() method:

modal.close();

If you don't have the instance reference (e.g. in the modal content page):

DayPilot.Modal.close();

If you call DayPilot.Modal.close() from the modal content you need to include modal.js in the content page as well.

Let me know if it didn't help.

Comment posted by mrplatypus
6 years ago.

Dan,

Forgot to add: the popup form also has an update panel..

Would that be preventing the close of the modal form?

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Yes, that might be the problem. The Modal.Close() method overrides the response. That's a kind of workaround which only works with the standard PostBack.

You'd have to replace it by injecting the client-side close() call in the button click handler using RegisterClientScriptBlock().

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Update: The latest version of DayPilot.Modal already uses RegisterClientSideScript() instead of response overriding so it should be compatible with UpdatePanel.

Comment posted by mrplatypus
6 years ago.

Dan,

Please would you provide me with the java script I'd need to add to the registerClientScriptBlock?

Is there much difference between the version 2.2 and 2.7 of the modal javascript file?
I'm mindful that making too many changes now would have unforeseen issues..

mrplatypus..

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.