Click here to Skip to main content
15,892,809 members
Articles / Web Development / HTML

The AnywherePlaceHolder. Part 3. The AnywhereValidationSummaryPlaceHolder

Rate me:
Please Sign up or sign in to vote.
3.92/5 (4 votes)
8 Sep 20054 min read 29.6K   385   25  
Eliminating the boundaries of frames. Writing your ASP.NET controls on any desired location in any frame.
using System;
using System.Text;
using System.Web.UI;
using System.Globalization;
using System.IO;

namespace DeKale.WebControls
{
	/// <summary>
	/// A simple AnywherePlaceHolder. Works fine for controls that output static
	/// html, contain no javascript functions, buttons and don't have to be referenced
	/// from javascript code.
	/// </summary>
	public class SimpleAnywherePlaceHolder : BaseAnywherePlaceHolder
	{
		/// <summary>Overridden.</summary>
		/// <param name="writer">The <see cref="System.Web.UI.HtmlTextWriter"/> object</param>
		protected override void Render(System.Web.UI.HtmlTextWriter writer)
		{
			// Checks if Properties are set correctly.
			this.PreRenderCheck();

			// Render the control
			base.Render(writer);

			// Check if the RenderMethod is RenderNormal. If so, than we're done.
			if (this.RenderMethod == AnywhereRenderMethodType.RenderNormal) return;

			// Create a HtmlTextWriter to buffer the output
			HtmlTextWriter buffer = new HtmlTextWriter(
				new StringWriter(CultureInfo.InvariantCulture));

			// get the output of the ChildControls in the buffer
			base.RenderChildren(buffer);

			// Put the buffered text into a string
			string renderedChildren = buffer.InnerWriter.ToString();

			// Write the call to the JavaScript function to the page.
			this.Page.ClientScript.RegisterStartupScript(
				this.GetType(),
				this.DestinationControlId,
				this.CreateScriptCall(renderedChildren),
				true
			);
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions