Click here to Skip to main content
12,502,836 members (54,716 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads

Stats

57.7K views
677 downloads
41 bookmarked
Posted

Enable ReadOnly Mode for your WebForms!

, 24 Feb 2004
This article will show you, how to implement a readonly mode for webforms.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Trivadis.Spieler.ReadOnly
{
	/// <summary>
	/// Summary description for ReadOnlyGridDialog.
	/// </summary>
	public class ReadOnlyGridDialog : BasePage
	{
		protected System.Web.UI.WebControls.ListBox lstHobbies;
		protected System.Web.UI.WebControls.Label lblHobby;
		protected System.Web.UI.WebControls.CheckBox chkSwiss;
		protected System.Web.UI.WebControls.Label lblSwiss;
		protected System.Web.UI.WebControls.RadioButtonList optCity;
		protected System.Web.UI.WebControls.Label lblCity;
		protected System.Web.UI.WebControls.DropDownList ddlSex;
		protected System.Web.UI.WebControls.Label lblSex;
		protected System.Web.UI.WebControls.TextBox txtFirstname;
		protected System.Web.UI.WebControls.Label lblFirstname;
		protected System.Web.UI.WebControls.TextBox txtLastname;
		protected System.Web.UI.WebControls.Label lblFirstnamed;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		protected System.Web.UI.WebControls.HyperLink hypGridLayout;
		protected System.Web.UI.WebControls.LinkButton lnkReadOnly;
		protected System.Web.UI.WebControls.Button btnSave;
		protected System.Web.UI.WebControls.RequiredFieldValidator reqFirstName;
		protected System.Web.UI.WebControls.LinkButton lnkBack;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!this.IsPostBack)
			{
				lnkBack.Attributes.Add("onclick","javascript:history.back(-1);");
				btnSave.Attributes.Add("onclick","javascript:alert('Not implemented now.');");
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.lnkReadOnly.Click += new System.EventHandler(this.lnkReadOnly_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void lnkReadOnly_Click(object sender, System.EventArgs e)
		{
			base.SetReadOnly(this.Controls);
		}
	}
}

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

Share

About the Author

Patrick Spieler
Web Developer
Switzerland Switzerland
Consultant for Trivadis AG in Switzerland.
Interested in .NET, Architectures, Patterns and Web 2.0.
Blog and articles at http://sharpcuts.blogspot.com

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 25 Feb 2004
Article Copyright 2004 by Patrick Spieler
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid