How can I save an ASP.NET IFRAME from a custom entity's OnSave event, reliably?

Posted by Forgotten Semicolon on Stack Overflow See other posts from Stack Overflow or by Forgotten Semicolon
Published on 2010-04-10T18:23:02Z Indexed on 2010/04/10 18:53 UTC
Read the original article Hit count: 214

I have a custom ASP.NET solution deployed to the ISV directory of an MS Dynamics CRM 4.0 application. We have created a custom entity, whose data entry requires more dynamism than is possible through the form builder within CRM. To accomplish this, we have created an ASP.NET form surfaced through an IFRAME on the entity's main form.

Here is how the saving functionality is currently laid out:

  1. There is an ASP.NET button control on the page that saves the entity when clicked. This button is hidden by CSS.
  2. The button click event is triggered from the CRM OnSave javascript event.
  3. The event fires and the entity is saved.

Here are the issues:

  1. When the app pool is recycled, the first save (or few) may:
    1. not save
    2. be delayed (ie. the interface doesn't show an update, until the page has been refreshed after a few sec)
  2. Save and Close/New may not save

For issue 1.1 and 2, what seems to be happening is that while the save event is fired for the custom ASP.NET page, the browser has moved on/refreshed the page, invalidating the request to the server. This results in the save not actually completing.

Right now, this is mitigated with a kludge javascript delay loop for a few seconds after calling the button save event, inside the entity OnSave event.

Is there any way to have the OnSave event wait for a callback from the IFRAME?

© Stack Overflow or respective owner

Related posts about dynamics-crm

Related posts about ASP.NET