Click here to Skip to main content
15,886,362 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.6K   726   41  
This article will show you, how to implement a readonly mode for webforms.
<%@ Page language="c#" Codebehind="ReadOnlyGridDialog.aspx.cs" AutoEventWireup="false" Inherits="Trivadis.Spieler.ReadOnly.ReadOnlyGridDialog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
		<title>ReadOnlyGridDialog</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 MS_POSITIONING="GridLayout">
		<FORM id="Form1" method="post" runat="server">
			<DIV style="Z-INDEX: 101; LEFT: 16px; WIDTH: 384px; POSITION: absolute; TOP: 8px; HEIGHT: 16px"
				ms_positioning="FlowLayout">
				<P><STRONG>Demo-Webform (GridLayout)</STRONG></P>
			</DIV>
			<DIV style="Z-INDEX: 102; LEFT: 16px; WIDTH: 414px; POSITION: absolute; TOP: 48px; HEIGHT: 264px; BACKGROUND-COLOR: lemonchiffon"
				ms_positioning="GridLayout"><asp:listbox id="lstHobbies" style="Z-INDEX: 104; LEFT: 192px; POSITION: absolute; TOP: 144px"
					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><asp:label id="lblSwiss" style="Z-INDEX: 112; LEFT: 192px; POSITION: absolute; TOP: 64px" runat="server"
					CssClass="lbl">Swiss</asp:label><asp:checkbox id="chkSwiss" style="Z-INDEX: 111; LEFT: 192px; POSITION: absolute; TOP: 88px" runat="server"
					Checked="True"></asp:checkbox><asp:radiobuttonlist id="optCity" style="Z-INDEX: 107; LEFT: 96px; POSITION: absolute; TOP: 88px" 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><asp:label id="lblCity" style="Z-INDEX: 113; LEFT: 96px; POSITION: absolute; TOP: 64px" runat="server"
					CssClass="lbl">City</asp:label><asp:label id="lblSex" style="Z-INDEX: 109; LEFT: 16px; POSITION: absolute; TOP: 64px" runat="server"
					CssClass="lbl">Sex</asp:label><asp:dropdownlist id="ddlSex" style="Z-INDEX: 106; LEFT: 16px; POSITION: absolute; TOP: 88px" runat="server">
					<asp:ListItem Value="Male">Male</asp:ListItem>
					<asp:ListItem Value="Female">Female</asp:ListItem>
				</asp:dropdownlist><asp:label id="lblFirstname" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 16px"
					runat="server" CssClass="lbl">First name</asp:label><asp:button id="btnSave" style="Z-INDEX: 108; LEFT: 280px; POSITION: absolute; TOP: 232px" runat="server"
					CssClass="btn" Width="75px" Text="Save"></asp:button><asp:label id="lblHobby" style="Z-INDEX: 105; LEFT: 192px; POSITION: absolute; TOP: 120px"
					runat="server" CssClass="lbl">Hobbies (MultiSelect)</asp:label><asp:textbox id="txtLastname" style="Z-INDEX: 110; LEFT: 144px; POSITION: absolute; TOP: 40px"
					runat="server" CssClass="txt" Width="150px">Spieler</asp:textbox><asp:label id="lblFirstnamed" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 40px"
					runat="server" CssClass="lbl">Last name</asp:label><asp:textbox id="txtFirstname" style="Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP: 16px"
					runat="server" CssClass="txt" Width="150px">Patrick</asp:textbox><asp:RequiredFieldValidator id=reqFirstName style="Z-INDEX: 114; LEFT: 256px; POSITION: absolute; TOP: 16px" runat="server" ErrorMessage="Required!" ControlToValidate="txtFirstname">*</asp:RequiredFieldValidator></DIV>
			<P></P>
			<P></P>
			<P></P>
			<P></P>
			<P></P>
			<P>
				<asp:HyperLink id="hypGridLayout" style="Z-INDEX: 103; LEFT: 208px; POSITION: absolute; TOP: 328px"
					runat="server" NavigateUrl="ReadOnlyDialog.aspx">Go to FlowLayout Demopage</asp:HyperLink><asp:LinkButton id=lnkReadOnly style="Z-INDEX: 104; LEFT: 24px; POSITION: absolute; TOP: 328px" runat="server">ReadOnly</asp:LinkButton><asp:LinkButton id=lnkBack style="Z-INDEX: 105; LEFT: 128px; POSITION: absolute; TOP: 328px" runat="server">Back</asp:LinkButton></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