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

Enable ReadOnly Mode for your WebForms!

Rate me:
Please Sign up or sign in to vote.
4.68/5 (20 votes)
24 Feb 2004 70.7K   726   41  
This article will show you, how to implement a readonly mode for webforms.
<%@ Page language="c#" Codebehind="ReadOnlyDialog.aspx.cs" AutoEventWireup="false" Inherits="Trivadis.Spieler.ReadOnly.ReadOnlyDialog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
		<title>ReadOnlyDialog</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="default.css" type="text/css" rel="stylesheet">
  </HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<P><STRONG>Demo-Webform (FlowLayout)</STRONG>
			</P>
			<P>
				<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" bgColor="whitesmoke" border="0">
					<TR>
						<TD width="100"><asp:label id="lblFirstnamed" runat="server" CssClass="lbl">Last name</asp:label></TD>
						<TD width="100"><asp:textbox id="txtLastname" runat="server" CssClass="txt" Width="150px">Spieler</asp:textbox></TD>
					</TR>
					<TR>
						<TD width="100"><asp:label id="lblFirstname" runat="server" CssClass="lbl">First name</asp:label></TD>
						<TD width="100">
							<P><asp:textbox id="txtFirstname" runat="server" CssClass="txt" Width="150px">Patrick</asp:textbox></P>
						</TD>
					</TR>
					<TR>
						<TD>
							<P><asp:label id="lblSex" runat="server" CssClass="lbl">Sex</asp:label></P>
						</TD>
						<TD><asp:dropdownlist id="ddlSex" runat="server">
								<asp:ListItem Value="Male">Male</asp:ListItem>
								<asp:ListItem Value="Female">Female</asp:ListItem>
							</asp:dropdownlist></TD>
					</TR>
					<TR>
						<TD width="100"><asp:label id="lblCity" runat="server" CssClass="lbl">City</asp:label></TD>
						<TD>
							<P><asp:radiobuttonlist id="optCity" runat="server" CssClass="lbl" BorderColor="Transparent">
									<asp:ListItem Value="Aarau">Aarau</asp:ListItem>
									<asp:ListItem Value="Basel">Basel</asp:ListItem>
									<asp:ListItem Value="Lugano">Lugano</asp:ListItem>
									<asp:ListItem Value="Z&#252;rich">Z&#252;rich</asp:ListItem>
								</asp:radiobuttonlist></P>
						</TD>
					</TR>
					<TR>
						<TD width="100"><asp:label id="lblSwiss" runat="server" CssClass="lbl">Swiss</asp:label></TD>
						<TD>
							<P><asp:checkbox id="chkSwiss" runat="server" Checked="True"></asp:checkbox></P>
						</TD>
					</TR>
					<TR>
						<TD width="100"><asp:label id="lblHobby" runat="server" CssClass="lbl">Hobbies (MultiSelect)</asp:label></TD>
						<TD>
							<P><asp:listbox id="lstHobbies" runat="server" CssClass="txt" Width="150px" SelectionMode="Multiple">
									<asp:ListItem Value="Sport">Sport</asp:ListItem>
									<asp:ListItem Value="Travelling">Travelling</asp:ListItem>
									<asp:ListItem Value="Computer">Computer</asp:ListItem>
									<asp:ListItem Value="Nature">Nature</asp:ListItem>
									<asp:ListItem Value="Wine">Wine</asp:ListItem>
								</asp:listbox></P>
						</TD>
					</TR>
					<TR>
						<TD width="100"></TD>
						<TD></TD>
					</TR>
					<TR>
						<TD width="100"></TD>
						<TD>
							<P><asp:button id=btnSave runat="server" CssClass="btn" Width="144px" Text="Save"></asp:button></P>
						</TD>
					</TR>
				</TABLE><BR><asp:LinkButton id=lnkReadOnly runat="server" DESIGNTIMEDRAGDROP="71">ReadOnly</asp:LinkButton>&nbsp; 
				<asp:LinkButton id=lnkBack runat="server" DESIGNTIMEDRAGDROP="71">Back</asp:LinkButton>&nbsp; 
				<asp:HyperLink id="hypGridLayout" runat="server" NavigateUrl="ReadOnlyGridDialog.aspx">Go to GridLayout Demopage</asp:HyperLink>
			</P>
		</form>
	</body>
</HTML>

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
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

Comments and Discussions