protected override void Render(HtmlTextWriter writer) { if(this.FormControl != null && this.XhtmlStrictRendering && writer.GetType() == typeof(HtmlTextWriter) && this.AdapterEnabled) { var w = new StrictHtmlTextWriter(writer); base.Render(w); } else { base.Render(writer); } }
/// <internalonly/> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Render(HtmlTextWriter output) { CacheDependency sqlCacheDep = null; // If the output is cached, use it and do nothing else if (_outputString != null) { output.Write(_outputString); RegisterValidationEvents(); return; } // If caching was turned off, just render the control if (_cachingDisabled || !RuntimeConfig.GetAppConfig().OutputCache.EnableFragmentCache) { _cachedCtrl.RenderControl(output); return; } // Create SQL cache dependency before we render the page if (_sqlDependency != null) { sqlCacheDep = SqlCacheDependency.CreateOutputCacheDependency(_sqlDependency); } _cacheEntry.CssStyleString = GetCssStyleRenderString(output.GetType()); // Create a new HtmlTextWriter, with the same type as the current one (see ASURT 118922) StringWriter tmpWriter = new StringWriter(); HtmlTextWriter tmpHtmlWriter = Page.CreateHtmlTextWriterFromType(tmpWriter, output.GetType()); CacheDependency cacheDep; TextWriter savedWriter = Context.Response.SwitchWriter(tmpWriter); try { // Make sure the Page knows about us while the control's OnPreRender is called Page.PushCachingControl(this); _cachedCtrl.RenderControl(tmpHtmlWriter); Page.PopCachingControl(); } finally { Context.Response.SwitchWriter(savedWriter); } _cacheEntry.OutputString = tmpWriter.ToString(); // Send the output to the response output.Write(_cacheEntry.OutputString); // Cache the output cacheDep = _cacheDependency; if (sqlCacheDep != null) { if (cacheDep == null) { cacheDep = sqlCacheDep; } else { AggregateCacheDependency aggr = new AggregateCacheDependency(); aggr.Add(cacheDep); aggr.Add(sqlCacheDep); cacheDep = aggr; } } ControlCachedVary cachedVary = null; string realItemCacheKey; // If there are no varies, use the non-varying key if (_varyByParamsCollection == null && _varyByControlsCollection == null && _varyByCustom == null) { realItemCacheKey = _cacheKey; } else { string[] varyByParams = null; if (_varyByParamsCollection != null) { varyByParams = _varyByParamsCollection.GetParams(); } cachedVary = new ControlCachedVary(varyByParams, _varyByControlsCollection, _varyByCustom); HashCodeCombiner combinedHashCode = new HashCodeCombiner(_nonVaryHashCode); realItemCacheKey = ComputeVaryCacheKey(combinedHashCode, cachedVary); } // Compute the correct expiration, sliding or absolute DateTime utcExpirationTime; TimeSpan slidingExpiration; if (_useSlidingExpiration) { utcExpirationTime = Cache.NoAbsoluteExpiration; slidingExpiration = _utcExpirationTime - DateTime.UtcNow; } else { utcExpirationTime = _utcExpirationTime; slidingExpiration = Cache.NoSlidingExpiration; } try { OutputCache.InsertFragment(_cacheKey, cachedVary, realItemCacheKey, _cacheEntry, cacheDep /*dependencies*/, utcExpirationTime, slidingExpiration, _provider); } catch { if (cacheDep != null) { cacheDep.Dispose(); } throw; } }
/// <internalonly/> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected internal override void Render(HtmlTextWriter output) { CacheDependency sqlCacheDep = null; // If the output is cached, use it and do nothing else if (_outputString != null) { output.Write(_outputString); RegisterValidationEvents(); return; } // If caching was turned off, just render the control if (_cachingDisabled || !RuntimeConfig.GetAppConfig().OutputCache.EnableFragmentCache) { _cachedCtrl.RenderControl(output); return; } // Create SQL cache dependency before we render the page if (_sqlDependency != null) { sqlCacheDep = SqlCacheDependency.CreateOutputCacheDependency(_sqlDependency); } _cacheEntry.CssStyleString = GetCssStyleRenderString(output.GetType()); // Create a new HtmlTextWriter, with the same type as the current one (see ASURT 118922) StringWriter tmpWriter = new StringWriter(); HtmlTextWriter tmpHtmlWriter = Page.CreateHtmlTextWriterFromType(tmpWriter, output.GetType()); CacheDependency cacheDep; TextWriter savedWriter = Context.Response.SwitchWriter(tmpWriter); try { // Make sure the Page knows about us while the control's OnPreRender is called Page.PushCachingControl(this); _cachedCtrl.RenderControl(tmpHtmlWriter); Page.PopCachingControl(); } finally { Context.Response.SwitchWriter(savedWriter); } _cacheEntry.OutputString = tmpWriter.ToString(); // Send the output to the response output.Write(_cacheEntry.OutputString); // Cache the output cacheDep = _cacheDependency; if (sqlCacheDep != null) { if (cacheDep == null) { cacheDep = sqlCacheDep; } else { AggregateCacheDependency aggr = new AggregateCacheDependency(); aggr.Add(cacheDep); aggr.Add(sqlCacheDep); cacheDep = aggr; } } ControlCachedVary cachedVary = null; string realItemCacheKey; // If there are no varies, use the non-varying key if (_varyByParamsCollection == null && _varyByControlsCollection == null && _varyByCustom == null) { realItemCacheKey = _cacheKey; } else { string[] varyByParams = null; if (_varyByParamsCollection != null) varyByParams = _varyByParamsCollection.GetParams(); cachedVary = new ControlCachedVary(varyByParams, _varyByControlsCollection, _varyByCustom); HashCodeCombiner combinedHashCode = new HashCodeCombiner(_nonVaryHashCode); realItemCacheKey = ComputeVaryCacheKey(combinedHashCode, cachedVary); } // Compute the correct expiration, sliding or absolute DateTime utcExpirationTime; TimeSpan slidingExpiration; if (_useSlidingExpiration) { utcExpirationTime = Cache.NoAbsoluteExpiration; slidingExpiration = _utcExpirationTime - DateTime.UtcNow; } else { utcExpirationTime = _utcExpirationTime; slidingExpiration = Cache.NoSlidingExpiration; } try { OutputCache.InsertFragment(_cacheKey, cachedVary, realItemCacheKey, _cacheEntry, cacheDep /*dependencies*/, utcExpirationTime, slidingExpiration, _provider); } catch { if (cacheDep != null) { cacheDep.Dispose(); } throw; } }
/// <include file='doc\PartialCachingControl.uex' path='docs/doc[@for="PartialCachingControl.Render"]/*' /> /// <internalonly/> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected override void Render(HtmlTextWriter output) { // If the output is cached, use it and do nothing else if (_outputString != null) { output.Write(_outputString); return; } // Create a new HtmlTextWriter, with the same type as the current one (see ASURT 118922) StringWriter tmpWriter = new StringWriter(); HtmlTextWriter tmpHtmlWriter = Page.CreateHtmlTextWriterFromType(tmpWriter, output.GetType()); TextWriter savedWriter = Context.Response.SwitchWriter(tmpWriter); try { _cachedCtrl.RenderControl(tmpHtmlWriter); } finally { Context.Response.SwitchWriter(savedWriter); } string outputString = tmpWriter.ToString(); // Send the output to the response output.Write(outputString); // Cache the output // Compute the expiration time DateTime utcExpires = DateTime.UtcNow.AddSeconds(_duration); HttpRuntime.CacheInternal.UtcInsert(_cacheKey, outputString, _cacheDependency /*dependencies*/, utcExpires, Cache.NoSlidingExpiration); }
protected override void Render(HtmlTextWriter writer) { if (!SiteUtils.UrlWasReWritten()) { try { // form action can't be empty string EnsureFormAction(); } catch (MissingMethodException) { //this method was introduced in .NET 3.5 SP1 } base.Render(writer); return; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Custom HtmlTextWriter to fix Form Action * Based on Jesse Ezell's "Fixing Microsoft's Bugs: URL Rewriting" * http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // this removes the action attribute from the form // so that it posts back correctly when using url re-writing //string rawUrl = Request.RawUrl; string action = Request.RawUrl; //if (Request.RawUrl.IndexOf(".aspx") > -1) //{ // action = Path.GetFileName(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf(".aspx") + 5)); //} //else //{ // action = Path.GetFileName(Request.RawUrl); //} // we need to append the query string to the form action // otherwise the params won't be available when the form posts back // example if editing an event ~/EventCalendarEdit.aspx??mid=4&pageid=3 // if the form action is merely "EventCalendarEdit.aspx" we won't have the // mid and pageid params on postback. querystring is only available in get requests // unless the form action includes it, then its also available in post requests if ( (appendQueryStringToAction) && (action.IndexOf("?") == -1) && (Request.QueryString.Count > 0) ) { action += "?" + Request.QueryString.ToString(); } if (action.Length == 0) { action = "/"; } if (writer.GetType() == typeof(HtmlTextWriter)) { writer = new MojoHtmlTextWriter(writer, action); } else if (writer.GetType() == typeof(Html32TextWriter)) { writer = new MojoHtml32TextWriter(writer, action); } base.Render(writer); }
protected override void Render(HtmlTextWriter writer) { // Render the content of this control to a string StringWriter sw = new StringWriter(); System.Reflection.ConstructorInfo constructor = writer.GetType().GetConstructor(new Type[] { sw.GetType() }); HtmlTextWriter htw = constructor.Invoke(new object[] {sw}) as HtmlTextWriter; base.RenderChildren(htw); htw.Close(); // Filter the string and write the result Filter f = new Filter(); f.ClientSideFilterName = ClientSideFilterName; f.SupportNoScriptTables = SupportNoScriptTables; f.MaxComplexity = MaxComplexity; f.TrustedImageUrlRegex = TrustedImageUrlRegex; f.SpamFreeLinkUrlRegex = SpamFreeLinkUrlRegex; writer.Write(f.FilterUntrusted(sw.ToString())); }
protected override void Render(HtmlTextWriter writer) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Custom HtmlTextWriter to fix Form Action * Based on Jesse Ezell's "Fixing Microsoft's Bugs: URL Rewriting" * http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // this removes the action attribute from the form // so that it posts back correctly when using url re-writing string action = Path.GetFileName(Request.RawUrl); if (action.IndexOf("?") == -1 && Request.QueryString.Count > 0) { action += "?" + Request.QueryString.ToString(); } if (writer.GetType() == typeof(HtmlTextWriter)) { writer = new MojoHtmlTextWriter(writer, action); } else if (writer.GetType() == typeof(Html32TextWriter)) { writer = new MojoHtml32TextWriter(writer, action); } base.Render(writer); }
protected override void Render(HtmlTextWriter writer) { globCal = DateTimeFormatInfo.CurrentInfo.Calendar; DateTime visDate = GetEffectiveVisibleDate(); DateTime firstDate = GetFirstCalendarDay(visDate); bool isEnabled; bool isHtmlTextWriter; //FIXME: when Control.Site works, reactivate this //if (Page == null || Site == null) { // isEnabled = false; // isHtmlTextWriter = false; //} else { isEnabled = Enabled; isHtmlTextWriter = (writer.GetType() != typeof(HtmlTextWriter)); //} defaultTextColor = ForeColor; if(defaultTextColor == Color.Empty) defaultTextColor = Color.Black; Table calTable = new Table (); calTable.ID = ID; calTable.CopyBaseAttributes(this); if(ControlStyleCreated) calTable.ApplyStyle(ControlStyle); calTable.Width = Width; calTable.Height = Height; calTable.CellSpacing = CellSpacing; calTable.CellPadding = CellPadding; if (ControlStyleCreated && ControlStyle.IsSet (WebControls.Style.BORDERWIDTH) && BorderWidth != Unit.Empty) calTable.BorderWidth = BorderWidth; else calTable.BorderWidth = Unit.Pixel(1); if (ShowGridLines) calTable.GridLines = GridLines.Both; else calTable.GridLines = GridLines.None; #if NET_2_0 calTable.Caption = Caption; calTable.CaptionAlign = CaptionAlign; #endif calTable.RenderBeginTag (writer); if (ShowTitle) RenderTitle (writer, visDate, SelectionMode, isEnabled); if (ShowDayHeader) RenderHeader (writer, firstDate, SelectionMode, isEnabled, isHtmlTextWriter); RenderAllDays (writer, firstDate, visDate, SelectionMode, isEnabled, isHtmlTextWriter); calTable.RenderEndTag(writer); }
protected internal override void Render(HtmlTextWriter output) { CacheDependency dependency = null; if (this._outputString != null) { output.Write(this._outputString); this.RegisterValidationEvents(); } else if (this._cachingDisabled || !RuntimeConfig.GetAppConfig().OutputCache.EnableFragmentCache) { this._cachedCtrl.RenderControl(output); } else { string str; DateTime noAbsoluteExpiration; TimeSpan noSlidingExpiration; if (this._sqlDependency != null) { dependency = SqlCacheDependency.CreateOutputCacheDependency(this._sqlDependency); } this._cacheEntry.CssStyleString = this.GetCssStyleRenderString(output.GetType()); StringWriter tw = new StringWriter(); HtmlTextWriter writer = Page.CreateHtmlTextWriterFromType(tw, output.GetType()); TextWriter writer3 = this.Context.Response.SwitchWriter(tw); try { this.Page.PushCachingControl(this); this._cachedCtrl.RenderControl(writer); this.Page.PopCachingControl(); } finally { this.Context.Response.SwitchWriter(writer3); } this._cacheEntry.OutputString = tw.ToString(); output.Write(this._cacheEntry.OutputString); CacheDependency dependencies = this._cacheDependency; if (dependency != null) { if (dependencies == null) { dependencies = dependency; } else { AggregateCacheDependency dependency3 = new AggregateCacheDependency(); dependency3.Add(new CacheDependency[] { dependencies }); dependency3.Add(new CacheDependency[] { dependency }); dependencies = dependency3; } } ControlCachedVary cachedVary = null; if (((this._varyByParamsCollection == null) && (this._varyByControlsCollection == null)) && (this._varyByCustom == null)) { str = this._cacheKey; } else { string[] varyByParams = null; if (this._varyByParamsCollection != null) { varyByParams = this._varyByParamsCollection.GetParams(); } cachedVary = new ControlCachedVary(varyByParams, this._varyByControlsCollection, this._varyByCustom); HashCodeCombiner combinedHashCode = new HashCodeCombiner(this._nonVaryHashCode); str = this.ComputeVaryCacheKey(combinedHashCode, cachedVary); } if (this._useSlidingExpiration) { noAbsoluteExpiration = Cache.NoAbsoluteExpiration; noSlidingExpiration = (TimeSpan)(this._utcExpirationTime - DateTime.UtcNow); } else { noAbsoluteExpiration = this._utcExpirationTime; noSlidingExpiration = Cache.NoSlidingExpiration; } try { OutputCache.InsertFragment(this._cacheKey, cachedVary, str, this._cacheEntry, dependencies, noAbsoluteExpiration, noSlidingExpiration, this._provider); } catch { if (dependencies != null) { dependencies.Dispose(); } throw; } } }
protected internal override void Render(HtmlTextWriter output) { CacheDependency dependency = null; if (this._outputString != null) { output.Write(this._outputString); this.RegisterValidationEvents(); } else if (this._cachingDisabled || !RuntimeConfig.GetAppConfig().OutputCache.EnableFragmentCache) { this._cachedCtrl.RenderControl(output); } else { string str; DateTime noAbsoluteExpiration; TimeSpan noSlidingExpiration; if (this._sqlDependency != null) { dependency = SqlCacheDependency.CreateOutputCacheDependency(this._sqlDependency); } this._cacheEntry.CssStyleString = this.GetCssStyleRenderString(output.GetType()); StringWriter tw = new StringWriter(); HtmlTextWriter writer = Page.CreateHtmlTextWriterFromType(tw, output.GetType()); TextWriter writer3 = this.Context.Response.SwitchWriter(tw); try { this.Page.PushCachingControl(this); this._cachedCtrl.RenderControl(writer); this.Page.PopCachingControl(); } finally { this.Context.Response.SwitchWriter(writer3); } this._cacheEntry.OutputString = tw.ToString(); output.Write(this._cacheEntry.OutputString); CacheDependency dependencies = this._cacheDependency; if (dependency != null) { if (dependencies == null) { dependencies = dependency; } else { AggregateCacheDependency dependency3 = new AggregateCacheDependency(); dependency3.Add(new CacheDependency[] { dependencies }); dependency3.Add(new CacheDependency[] { dependency }); dependencies = dependency3; } } ControlCachedVary cachedVary = null; if (((this._varyByParamsCollection == null) && (this._varyByControlsCollection == null)) && (this._varyByCustom == null)) { str = this._cacheKey; } else { string[] varyByParams = null; if (this._varyByParamsCollection != null) { varyByParams = this._varyByParamsCollection.GetParams(); } cachedVary = new ControlCachedVary(varyByParams, this._varyByControlsCollection, this._varyByCustom); HashCodeCombiner combinedHashCode = new HashCodeCombiner(this._nonVaryHashCode); str = this.ComputeVaryCacheKey(combinedHashCode, cachedVary); } if (this._useSlidingExpiration) { noAbsoluteExpiration = Cache.NoAbsoluteExpiration; noSlidingExpiration = (TimeSpan) (this._utcExpirationTime - DateTime.UtcNow); } else { noAbsoluteExpiration = this._utcExpirationTime; noSlidingExpiration = Cache.NoSlidingExpiration; } try { OutputCache.InsertFragment(this._cacheKey, cachedVary, str, this._cacheEntry, dependencies, noAbsoluteExpiration, noSlidingExpiration, this._provider); } catch { if (dependencies != null) { dependencies.Dispose(); } throw; } } }