示例#1
0
        /// <summary>
        /// Occurs when a new update is added to the Live Editing update collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UpdateAddedEventArgs"/> instance containing the event data.</param>
        protected void Updates_UpdateAdded(object sender, UpdateAddedEventArgs e)
        {
            ItemUpdate update = e.Update as ItemUpdate;

            if (update != null)
            {
                List <Item> affectedItems = Utility.FindControls <Item>(item => item.GetParsedNodeId() == update.NodeId &&
                                                                        item.Field == update.Field,
                                                                        Page.Master);
                foreach (Item affectedItem in affectedItems)
                {
                    // render the item, temporarily disabling the live editing special output
                    StringWriter itemRenderOutput       = new StringWriter();
                    bool         liveEditingWasDisabled = affectedItem.LiveEditingDisabled;
                    affectedItem.LiveEditingDisabled = true;
                    affectedItem.RenderControl(new HtmlTextWriter(itemRenderOutput));
                    affectedItem.LiveEditingDisabled = liveEditingWasDisabled;

                    // add the item's contents to the output
                    HtmlGenericControl itemUpdate = new HtmlGenericControl("umbraco:itemupdate");
                    itemUpdate.Attributes["itemId"] = affectedItem.ItemId.ToString();
                    itemUpdate.InnerHtml            = template.ParseInternalLinks(itemRenderOutput.ToString());
                    itemUpdate.EnableViewState      = false;
                    m_Manager.AddClientOutput(itemUpdate);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Occurs when a new update is added to the Live Editing update collection.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UpdateAddedEventArgs"/> instance containing the event data.</param>
        protected void Updates_UpdateAdded(object sender, UpdateAddedEventArgs e)
        {
            ItemUpdate update = e.Update as ItemUpdate;
            if (update != null)
            {
                List<Item> affectedItems = Utility.FindControls<Item>(item => item.GetParsedNodeId() == update.NodeId
                                                                           && item.Field == update.Field,
                                                                      Page.Master);
                foreach (Item affectedItem in affectedItems)
                {
                    // render the item, temporarily disabling the live editing special output
                    StringWriter itemRenderOutput = new StringWriter();
                    bool liveEditingWasDisabled = affectedItem.LiveEditingDisabled;
                    affectedItem.LiveEditingDisabled = true;
                    affectedItem.RenderControl(new HtmlTextWriter(itemRenderOutput));
                    affectedItem.LiveEditingDisabled = liveEditingWasDisabled;

                    // add the item's contents to the output
                    HtmlGenericControl itemUpdate = new HtmlGenericControl("umbraco:itemupdate");
                    itemUpdate.Attributes["itemId"] = affectedItem.ItemId.ToString();
					itemUpdate.InnerHtml = TemplateUtilities.ParseInternalLinks(itemRenderOutput.ToString());
                    itemUpdate.EnableViewState = false;
                    m_Manager.AddClientOutput(itemUpdate);
                }
            }
        }