Prevent update panel blink in parent when __doPostBack() is called

Last post 07-05-2009 10:50 PM by chetan.sarode. 2 replies.

Sort Posts:

  • Prevent update panel blink in parent when __doPostBack() is called

    07-03-2009, 10:01 AM
    • Member
      point Member
    • metaller
    • Member since 12-05-2006, 7:54 AM
    • Bratislava, Slovakia
    • Posts 19

    Hello there,

    I've some problem with update panel (UP) in parent form blinking after __doPostBack() from child is called

    When i do some action, like update som record in child (popup) window, I want to close the window, and force postback to parent.

    Problem is, that after this, althought that page content is in UP, the page blinks...

    this is the script I call from child

    if (!Page.ClientScript.IsStartupScriptRegistered("CloseAjaxWithReload"))
    {
        // Prepare the script to close the window
        StringBuilder script = new StringBuilder();
        script.Append("<script type=\"text/javascript\">");
        script.Append("window.open('', '_self', '');");
        script.Append("window.opener.__doPostBack('child');");
        script.Append("window.close();");
        script.Append("</script>");
    
        ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseAjaxWithReload", script.ToString(), false);
    }


    Then in parent's page load, I catch, that postback was forced by child.


    protected void Page_Load(object sender, EventArgs e)
    {
        
        string eventTarget = (this.Request["__EVENTTARGET"] == null) ? string.Empty : this.Request["__EVENTTARGET"];
    
        if (!IsPostBack)
        {
            // Do nothing
        }
        else
        {
            if (eventTarget == "child")
            {
                // Call listview databind
                ReloadList();
            }  
        }
    }

    Whole content is in masterpage content and in UP.

    <asp:Content ID="AccountListContent" ContentPlaceHolderID="cphContent" runat="server">
    
    <asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="cphContent" />
        </Triggers>    
        <ContentTemplate>
               //page content is here, also the listview
        </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Content>


    Everithing work's fine, except the page blink.

    Any idea why is the page blinking???

    Thx for any help, suggestion, whatever :)


    Filed under:
  • Re: Prevent update panel blink in parent when __doPostBack() is called

    07-04-2009, 12:48 PM
    • Participant
      1,157 point Participant
    • Ibro
    • Member since 10-08-2008, 2:17 PM
    • Posts 373

     This blink is something I have come accross and I think is something caused by the Ajax,

    does this reply help you? mark as an answer
    Ibro
  • Re: Prevent update panel blink in parent when __doPostBack() is called

    07-05-2009, 10:50 PM
    Answer

    How UpdatePanel Controls Are Refreshed

    The following list describes the property settings of the UpdatePanel control that determine when a panel's content is updated during partial-page rendering.

    • If the UpdateMode property is set to Always, the UpdatePanel control’s content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls that are inside other UpdatePanel controls, and postbacks from controls that are not inside UpdatePanel controls.

    • If the UpdateMode property is set to Conditional, the UpdatePanel control’s content is updated when one of the following is true:

      • When the postback is caused by a trigger for that UpdatePanel control.

      • When you explicitly call the UpdatePanel control's Update() method.

      • When the UpdatePanel control is nested inside another UpdatePanel control and the parent panel is updated.

      • When the ChildrenAsTriggers property is set to true and any child control of the UpdatePanel control causes a postback. Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers for the parent panel.

    If the ChildrenAsTriggers property is set to false and the UpdateMode property is set to Always, an exception is thrown. The ChildrenAsTriggers property is intended to be used only when the UpdateMode property is set to Conditional.

    http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
Page 1 of 1 (3 items)