Click here to Skip to main content
15,896,201 members
Articles / Web Development / IIS

Rapid Web Application Development

Rate me:
Please Sign up or sign in to vote.
4.00/5 (5 votes)
27 Sep 200510 min read 204.1K   4.2K   86  
An article about the Multiformity Open Source project.
using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using rasp.SQL;
using rasp.SQL.SQLStatement;
using rasp.SQL.DBInfo;

namespace rasp.HTML.Controls {
	/// <summary>
	/// A RaspButton is actually a placeholder, with a button on it, and it implements IWebControl.
	/// </summary>
	public class RaspButton : PlaceHolder, IButton {
		IButton mb;
		private ButtonTypes _ButtonType;
		/// <summary>
		/// Constructs a new RaspButton.
		/// </summary>
		public RaspButton() {
			mb = (IButton)new RaspButtonInput();
			Controls.Add((WebControl)mb);
		}

		public RaspButton(ButtonTypes bt) {
			_ButtonType = bt;
			switch(bt) {
				case ButtonTypes.Default:
					mb = (IButton)new RaspButtonInput();
					Controls.Add((WebControl)mb);
					break;
				case ButtonTypes.Image:
					mb = (IButton)new RaspImageButton();
					Controls.Add((WebControl)mb);
					break;
				case ButtonTypes.Text:
					break;
			}
		}

		/// <summary>
		/// Gets the AttributeCollection of the button.
		/// </summary>
		public AttributeCollection Attributes {
			get {
				return mb.Attributes;
			}
		}
		/// <summary>
		/// The mouseover description for the button.
		/// </summary>
		public string ToolTip { 
			get {
				return mb.ToolTip;
			}
			set {
				mb.ToolTip = value;
			}
		}
		/// <summary>
		/// Determines if the button should cause validation to occur.
		/// </summary>
		public bool CausesValidation { 
			get {
				return mb.CausesValidation;
			}
			set {
				mb.CausesValidation = value;
			}
		}
		/// <summary>
		/// Adds the provided EventHandler to the buttons Click event.
		/// </summary>
		/// <param name="eh">The EventHandler to add.</param>
		public void SetClick(System.EventHandler eh) {
			mb.SetClick(eh);
		}		

		
		/// <summary>
		/// Gets or sets the text of the button.
		/// </summary>
		public string Text { 
			get{
				return mb.Text;
			}
			set{
				mb.Text = value;
			}
		}
		/// <summary>
		/// Gets or sets the Buttons ID property.
		/// </summary>
		override public string ID {
			get{
				return mb.ID;
			}
			set{
				mb.ID = value;
			}
		}
		/// <summary>
		/// Gets or sets the Buttons width.
		/// </summary>
		public Unit Width {
			get{
				return mb.Width;
			}
			set{
				mb.Width = value;
			}
		}
		/// <summary>
		/// Hides the button and returns a RaspHidden web control.
		/// </summary>
		/// <remarks>
		/// This is most likley never called, but is required by the IWebControl interface.
		/// </remarks>
		/// <returns>A RaspHidden control.</returns>
		public WebControl Hide() {
			return Tools.Hide(this);
		}
	}


	/// <summary>
	/// Implements the default button.
	/// </summary>
	public class RaspButtonInput : Button, IButton {


		/// <summary>
		/// Sets the provided EventHandler to the buttons Click event, removing all other events.
		/// </summary>
		/// <param name="eh">The EventHandler to add.</param>
		public void SetClick(EventHandler eh) {
			Click += eh;
		}

		/// <summary>
		/// Hides the button and returns a RaspHidden web control.
		/// </summary>
		/// <remarks>
		/// This is most likley never called, but is required by the IWebControl interface.
		/// </remarks>
		/// <returns>A RaspHidden control.</returns>
		public WebControl Hide() {
			return Tools.Hide(this);
		}		
	}
	
	public class RaspImageButton : ImageButton, IButton {
		private ArrayList _Events = new ArrayList();

		public void _Click(object Sender, ImageClickEventArgs args) {
			foreach(EventHandler eh in _Events) {
                try {
                    eh.Method.Invoke(eh.Target, new object[2] { Sender, null });
                }
                catch { }
			}
		}
		public RaspImageButton() {
			Click += new ImageClickEventHandler(_Click);
		}
		/// <summary>
		/// Adds the provided EventHandler to the buttons Click event.
		/// </summary>
		/// <param name="eh">The EventHandler to add.</param>
		public void SetClick(EventHandler eh) {
			_Events.Add(eh);			
		}




		/// <summary>
		/// Gets or sets the text of the button.
		/// </summary>
		public string Text { 
			get{
				return ImageUrl;
			}
			set{
				ImageUrl = value;
			}
		}


		/// <summary>
		/// Hides the button and returns a RaspHidden web control.
		/// </summary>
		/// <remarks>
		/// This is most likley never called, but is required by the IWebControl interface.
		/// </remarks>
		/// <returns>A RaspHidden control.</returns>
		public WebControl Hide() {
			return Tools.Hide(this);
		}
	}
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions