Clearing+a+form

Since we haven't been taught this, I figured I'd throw what I found up here. This is the Default.aspx.cs file (ie: the code) code format="csharp" using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;

public partial class Default2 : System.Web.UI.Page {    protected void ButtonClear_Click(object sender, EventArgs e)     { Box1.Text = ""; } } code

Below is the default.aspx file.

code format="html4strict" <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 Untitled Page    code

Clearing Form Fields without initiating Validation Controls
Most validation controls will execute whenever any button on the form is clicked. This is problematic for a Clear button as you don't expect the data in the form fields to be valid (why else would the user be clearing it).

To override this behavior, simply add the following attribute to your button control:

code format="csharp"  code