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

Automatic Error Handling

Rate me:
Please Sign up or sign in to vote.
4.78/5 (10 votes)
17 Mar 2008CPOL3 min read 57.2K   1.1K   74  
Handle web and WinForms exceptions automatically.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Exception Handler Test</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
					&nbsp;<asp:TextBox ID="_textBox" runat="server" Columns="55">The quick brown fox jumped over the high fence at the zoo.</asp:TextBox>
					<br />
					<br />
					<asp:DropDownList ID="_dropDownList" runat="server">
						<asp:ListItem>Item1</asp:ListItem>
						<asp:ListItem Selected="True">Item2</asp:ListItem>
						<asp:ListItem>Item3</asp:ListItem>
					</asp:DropDownList>&nbsp;
					<asp:CheckBox ID="_checkBox" runat="server" Text="Check Box" />
					<br />
					<br />
					<asp:Calendar ID="_calendar" runat="server" BackColor="White" BorderColor="#999999"
						CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
						Height="180px" Width="200px">
						<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
						<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
						<SelectorStyle BackColor="#CCCCCC" />
						<WeekendDayStyle BackColor="#FFFFCC" />
						<OtherMonthDayStyle ForeColor="#808080" />
						<NextPrevStyle VerticalAlign="Bottom" />
						<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
						<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
					</asp:Calendar>
					<br />
					<asp:ListBox ID="_listBox" runat="server" Rows="3" SelectionMode="Multiple">
						<asp:ListItem Selected="True">Item1</asp:ListItem>
						<asp:ListItem>Item2</asp:ListItem>
						<asp:ListItem Selected="True">Item3</asp:ListItem>
					</asp:ListBox>
        </div>
			<br />
			<br />
			<asp:Button ID="_button" runat="server" OnClick="_button_Click" Text="Throw Exception" />
    </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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Belami
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