Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 826753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:27:52+00:00 2026-05-15T03:27:52+00:00

I have a custom ASP.NET solution deployed to the ISV directory of an MS

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:27:53+00:00Added an answer on May 15, 2026 at 3:27 am

    The solution that I’ve implemented (very recently) to overcome the problem is a little complicated, but let me try to explain:

    Essentially – On the page with the iFrame, you’re going to track (in Session) the save event and expose the results through a WebMethod that the CRM page will call (using the jquery .ajax() functionality)

    Best way to explain is with sample code (Just create a new Website Project with Default.aspx & IFramePage.aspx):

    IFramePage.aspx ->

        <script type="text/javascript">
    
        SaveStuff = function() {            
            __doPostBack('SaveButton', '');
        }
    
    </script>    
        Hello - I am an iFrame!<br />
        <asp:linkbutton id="SaveButton" runat="server" style="display:none;" onclick="SaveButton_Click" text="Save" />
        <asp:hiddenfield id="RandomGuidHiddenField" runat="server" />
    </div>
    

    IFramePage.aspx.cs ->

        public static object locker = new object();
    
    /// <summary>
    /// Gets the statuses.
    /// </summary>
    /// <value>The statuses.</value>
    public static Dictionary<Guid, bool> Statuses
    {
        get 
        {
            lock (locker)
            {
                if (HttpContext.Current.Session["RandomGuid"] == null)
                {
                    HttpContext.Current.Session["RandomGuid"] = new Dictionary<Guid, bool>();
                }
    
                return (Dictionary<Guid, bool>) HttpContext.Current.Session["RandomGuid"];
            }
        }
    }
    
    [WebMethod]
    public static bool CheckSaveComplete(string randomGuid)
    {
        var currentGuid = new Guid(randomGuid);
        var originalTime = DateTime.Now;
    
        if (!Statuses.ContainsKey(currentGuid))
        {
            Statuses.Add(currentGuid, false);
        }
    
        while (!Statuses[currentGuid])
        {
            if (DateTime.Now.Subtract(originalTime) > new TimeSpan(0, 0, 0, 1))
            {
                return false;
            }
    
            Thread.Sleep(1000);
        }
    
        return true;
    }
    
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.RandomGuidHiddenField.Value = Guid.NewGuid().ToString();            
        }
    }
    
    /// <summary>
    /// Handles the Click event of the SaveButton control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        var randomGuid = new Guid(this.RandomGuidHiddenField.Value);
    
        if (!Statuses.ContainsKey(randomGuid))
        {
            Statuses.Add(randomGuid, false);
        }
    
        Thread.Sleep(10000);
    
        Statuses[randomGuid] = true;
    }
    

    In my Default.aspx page (to simulate the CRM Form Entity page) ->

       <script type="text/javascript">
        function OnSave() {
            var saveResult = false;
            var randomGuid = window.frames[$("#daIframe")[0].id].$("input[id$=RandomGuidHiddenField]").val();
    
            window.frames[$("#daIframe")[0].id].SaveStuff();
    
    
            $.ajax(
            {
                async: false,
                type: "POST",
                url: "IFramePage.aspx/CheckSaveComplete",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: '{"randomGuid" : "' + randomGuid + '"}',
                success: function(response) {
                    if (response.d === true) {
                        alert(response.d);
                        saveResult = true;
                    }
                }
            }
            );
    
        if (saveResult !== true) {
            alert("Oh No!");
        }
        else {
            alert("way to go!");
        }
    }
    
    </script>
    <iframe name="daIframe" id="daIframe" src="IFramePage.aspx"></iframe>
    <asp:textbox id="lsc_paymentinfo" runat="server" text="1000" /><br />
    <input type="button" value="Save" onclick="OnSave();" />
    

    Let me know if you have any questions!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my asp.net mvc3 application, I have a custom Authorization Attribute as seen below.
I have an ASP.NET application that uses a custom .NET library (a .DLL file).
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]
I have an ASP.NET MVC 2 application with a custom StructureMap controller factory to
I have an MVC 3 application which uses asp.net authentication. I have just created
I have an existing ASP.NET website with some custom routing, within a Solution that
I have one asp.net mvc 3 application (www.name.com) with custom module added to web.config:
I have a Visual Studio 2008 solution with an ASP.NET Web Application project. I
I have a dynamic data ASP.NET application with a requirement to give some users
I have a custom Asp.net control as public class ImageControl : Panel { private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.