protected virtual IEnumerable <ScriptDescriptor> GetScriptDescriptors()
        {
            // Don't render any scripts when partial rendering is not enabled
            if (Page != null && ScriptManager.SupportsPartialRendering && Visible)
            {
                ScriptControlDescriptor desc = new ScriptControlDescriptor("Sys.UI._UpdateProgress", ClientID);
                string updatePanelClientID   = null;
                if (!String.IsNullOrEmpty(AssociatedUpdatePanelID))
                {
                    // Try both the NamingContainer and the Page
                    UpdatePanel c = ControlUtil.FindTargetControl(AssociatedUpdatePanelID, this, true) as UpdatePanel;
                    if (c != null)
                    {
                        updatePanelClientID = c.ClientID;
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdateProgress_NoUpdatePanel, AssociatedUpdatePanelID));
                    }
                }
                desc.AddProperty("associatedUpdatePanelId", updatePanelClientID);
                desc.AddProperty("dynamicLayout", DynamicLayout);
                desc.AddProperty("displayAfter", DisplayAfter);
                yield return(desc);
            }

            yield break;
        }
Esempio n. 2
0
        protected Control FindTargetControl(bool searchNamingContainers)
        {
            if (String.IsNullOrEmpty(ControlID))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdatePanelControlTrigger_NoControlID, Owner.ID));
            }
            Control foundControl = ControlUtil.FindTargetControl(ControlID, Owner, searchNamingContainers);

            if (foundControl == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdatePanelControlTrigger_ControlNotFound, ControlID, Owner.ID));
            }
            return(foundControl);
        }
Esempio n. 3
0
        private void RenderPageCallback(HtmlTextWriter writer, Control pageControl)
        {
            ProcessUpdatePanels();

            // Although we could use the pageControl parameter it's hard to write
            // unit tests for it. Instead we just use our own page, which is the
            // same instance anyway (but easier to test with).

            HttpResponseBase response = _owner.IPage.Response;

            response.ContentType = "text/plain";
            response.Cache.SetNoServerCaching();

            // Write out the version identifier, which helps the client-side deal with the response
            // in a back-compatible way when there are changes made server-side.
            EncodeString(writer, UpdatePanelVersionToken, String.Empty, UpdatePanelVersionNumber);

            // Render the form. It will render its tag, hidden fields, etc.
            // and then call our render method delegate, which will in turn render
            // all the UpdatePanels
            IHtmlForm formControl = _owner.IPage.Form;

            formControl.SetRenderMethodDelegate(RenderFormCallback);

            // Let updatePanels write directly to Response
            _updatePanelWriter = writer;

            // Let form header/footer write to a parser
            ParserHtmlTextWriter formWriter = new ParserHtmlTextWriter();

            formControl.RenderControl(formWriter);

            // Write out built-in ASP.NET hidden fields that were rendered directly by the page
            // or registered through RegisterHiddenField
            var hiddenFields = _owner.IPage.HiddenFieldsToRender;

            if (hiddenFields != null)
            {
                foreach (KeyValuePair <String, String> entry in hiddenFields)
                {
                    if (ControlUtil.IsBuiltInHiddenField(entry.Key))
                    {
                        EncodeString(writer, HiddenFieldToken, entry.Key, entry.Value);
                    }
                }
            }

            // Write out PageRequestManager settings that can change during an async postback.
            // This is required for dynamic UpdatePanels since the list of panels could
            // change.
            EncodeString(writer, AsyncPostBackControlIDsToken, String.Empty, GetAsyncPostBackControlIDs(false));
            EncodeString(writer, PostBackControlIDsToken, String.Empty, GetPostBackControlIDs(false));
            EncodeString(writer, UpdatePanelIDsToken, String.Empty, GetAllUpdatePanelIDs());
            EncodeString(writer, ChildUpdatePanelIDsToken, String.Empty, GetChildUpdatePanelIDs());
            EncodeString(writer, UpdatePanelsToRefreshToken, String.Empty, GetRefreshingUpdatePanelIDs());
            EncodeString(writer, AsyncPostBackTimeoutToken, String.Empty, _owner.AsyncPostBackTimeout.ToString(CultureInfo.InvariantCulture));
            if (formWriter.FormAction != null)
            {
                EncodeString(writer, FormActionToken, String.Empty, formWriter.FormAction);
            }
            if (_owner.IPage.Header != null)
            {
                string pageTitle = _owner.IPage.Title;
                if (!String.IsNullOrEmpty(pageTitle))
                {
                    EncodeString(writer, PageTitleToken, String.Empty, pageTitle);
                }
            }
            RenderDataItems(writer);

            ProcessScriptRegistration(writer);

            // We process the focus after regular script registrations to
            // make sure that if it ends up including some script that it
            // executes last.
            ProcessFocus(writer);
        }