Click here to Skip to main content
15,887,992 members
Articles / Web Development / ASP.NET

ASP.NET Ajax Controls to Simulate IFrame

Rate me:
Please Sign up or sign in to vote.
4.55/5 (7 votes)
8 Nov 2009CPOL2 min read 50.1K   2.1K   44  
An Ajax control to simulate IFrame. It works like Microsoft MSDN Library site.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace Symber.Web.APX
{
	[ParseChildren(true)]
	[PersistChildren(false)]
	public class APXAccordionPane : WebControl
	{
		#region [ Fields ]

		private APXAccordionContentPanel _header;
		private APXAccordionContentPanel _content;
		private ITemplate _headerTemplate;
		private ITemplate _contentTemplate;

		#endregion

		#region [ Properties ]

		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public APXAccordionContentPanel HeaderContainer
		{
			get
			{
				EnsureChildControls();
				return _header;
			}
		}

		[Browsable(true)]
		[Category("Appearance")]
		[Description("CSS class for Accordion Pane Header")]
		public string HeaderCssClass
		{
			get
			{
				EnsureChildControls();
				return _header.CssClass;
			}
			set
			{
				EnsureChildControls();
				_header.CssClass = value;
			}
		}

		[Browsable(false)]
		[DefaultValue(null)]
		[Description("Accordion Pane Header")]
		[PersistenceMode(PersistenceMode.InnerProperty)]
		[TemplateContainer(typeof(APXAccordionContentPanel))]
		[TemplateInstance(TemplateInstance.Single)]
		public virtual ITemplate Header
		{
			get { return _headerTemplate; }
			set { _headerTemplate = value; }
		}

		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public APXAccordionContentPanel ContentContainer
		{
			get
			{
				EnsureChildControls();
				return _content;
			}
		}

		[Browsable(true)]
		[Category("Appearance")]
		[Description("CSS class for Accordion Pane Content")]
		public string ContentCssClass
		{
			get
			{
				EnsureChildControls();
				return _content.CssClass;
			}
			set
			{
				EnsureChildControls();
				_content.CssClass = value;
			}
		}

		[Browsable(false)]
		[DefaultValue(null)]
		[Description("Accordion Pane Content")]
		[PersistenceMode(PersistenceMode.InnerProperty)]
		[TemplateContainer(typeof(APXAccordionContentPanel))]
		[TemplateInstance(TemplateInstance.Single)]
		public virtual ITemplate Content
		{
			get { return _contentTemplate; }
			set { _contentTemplate = value; }
		}

		#endregion

		#region [ Override Implementation of WebControl ]

		public override ControlCollection Controls
		{
			get
			{
				EnsureChildControls();
				return base.Controls;
			}
		}

		protected override void CreateChildControls()
		{
			// Create the controls
			Controls.Clear();
			Controls.Add(_header = new APXAccordionContentPanel(null, -1, APXAccordionItemType.Header));
			Controls.Add(_content = new APXAccordionContentPanel(null, -1, APXAccordionItemType.Content));

			// By default, collapse the content sections so the
			// page loads without flicker (the selected section
			// will be expanded again in the parent Accordion's
			// OnPreRender)
			_content.Collapsed = true;

			// Load the templates into the controls
			if (_headerTemplate != null)
				_headerTemplate.InstantiateIn(_header);
			if (_contentTemplate != null)
				_contentTemplate.InstantiateIn(_content);
		}

		public override Control FindControl(string id)
		{
			EnsureChildControls();
			return base.FindControl(id) ?? _header.FindControl(id) ?? _content.FindControl(id);
		}

		public override void RenderBeginTag(HtmlTextWriter writer)
		{
			// Do not call base.RenderBeginTag...
		}

		public override void RenderEndTag(HtmlTextWriter writer)
		{
			// Do not call base.RenderEndTag...
		}

		#endregion
	}
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer APEnnead.net Term
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions