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

Web User Forms for ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.90/5 (52 votes)
18 Sep 2012CPOL12 min read 135.2K   4.5K   187  
User driven runtime dynamic ASP.NET Web Forms
// -- FILE ------------------------------------------------------------------
// name       : LookupsUserForm.cs
// project    : Itenso Web User Forms
// created    : Jani Giannoudis - 2008.10.30
// language   : c#
// environment: .NET 2.0
// copyright  : (c) 2008-2012 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
using System;
using System.Web.UI;
using Itenso.WebUserForms.Controls;
using Itenso.WebUserForms.Runtime;

// --------------------------------------------------------------------------
public partial class LookupsPage : Page
{

	// ------------------------------------------------------------------------
	protected override void OnLoad( EventArgs e )
	{
		// load form control
		userForm = new UserFormLoader( "~/UserForms/LookupsUserForm.ascx" ).Load();

		// lookup
		LookupAdapter.Apply( DemoLookupProvider.Instance, userForm );

		FormPlaceHolder.Controls.Add( userForm );

		base.OnLoad( e );
	} // OnLoad

	// ------------------------------------------------------------------------
	private void SetEditMode( bool allowEdit )
	{
		FieldEditEnabler.Enable( userForm, allowEdit );
		SubmitButton.Enabled = allowEdit;
		EditButton.Enabled = !allowEdit;
	} // SetEditMode

	// ------------------------------------------------------------------------
	protected void SubmitButton_Click( object sender, EventArgs e )
	{
		SetEditMode( false );
	} // SubmitButton_Click

	// ------------------------------------------------------------------------
	protected void EditButton_Click( object sender, EventArgs e )
	{
		SetEditMode( true );
	} // EditButton_Click

	// ------------------------------------------------------------------------
	protected void ClearLookups_Click( object sender, EventArgs e )
	{
		DemoLookupProvider.Instance.Clear();
	} // ClearLookups_Click

	// ------------------------------------------------------------------------
	// members
	private UserControl userForm;

} // class LookupsPage
// -- EOF -------------------------------------------------------------------

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
Software Developer (Senior)
Switzerland Switzerland
👨 Senior .NET Software Engineer

🚀 My Open Source Projects
- Time Period Library 👉 GitHub
- Payroll Engine 👉 GitHub

Feedback and contributions are welcome.



Comments and Discussions