Ejemplo n.º 1
0
    protected override void Render(HtmlTextWriter writer)
    {
        if (_requestCompleted)
        {
            return;
        }

        if (_pageEventsPageMeasuring != null)
        {
            _pageEventsPageMeasuring.Dispose();
        }

        ScriptManager scriptManager         = ScriptManager.GetCurrent(this);
        bool          isUpdatePanelPostback = scriptManager != null && scriptManager.IsInAsyncPostBack;

        if (isUpdatePanelPostback)
        {
            base.Render(writer);
            return;
        }

        if (_renderingContext.PreRenderRedirectCheck())
        {
            return;
        }

        var markupBuilder = new StringBuilder();
        var sw            = new StringWriter(markupBuilder);

        try
        {
            using (Profiler.Measure("ASP.NET controls: Render"))
            {
                base.Render(new HtmlTextWriter(sw));
            }
        }
        catch (HttpException ex)
        {
            CheckForMultipleAspNetFormsException(ex);
            throw;
        }

        string xhtml = _renderingContext.ConvertInternalLinks(markupBuilder.ToString());

        if (GlobalSettingsFacade.PrettifyPublicMarkup)
        {
            xhtml = _renderingContext.FormatXhtml(xhtml);
        }

        // Inserting perfomance profiling information
        if (_renderingContext.ProfilingEnabled)
        {
            xhtml = _renderingContext.BuildProfilerReport();

            Response.ContentType = "text/xml";
        }

        writer.Write(xhtml);
    }