great way to clear asp.net form fields
The Weird and The Wonderful
1
Posts
1
Posters
1
Views
1
Watching
-
I am updating an asp.net application developed by someone else to use master pages, and I was getting a NullReferenceException with the following lines:
Line 61: }
Line 62: if (IsRequiredField('<%= txtExpDate.ClientID %>', 'Expiry Date', errorLbl) == false)
Line 63: if (f.value==1)After some time to figure out what was happening, I found this perfect way to clear asp.net controls :((:
private void ClearFields()
{
this.txtCouponCode.Text="";
this.txtCouponName.Text="";
this.txtDiscount.Text="";
this.txtNoUses.Text="";
this.ddlNoUses.SelectedIndex=1;
this.txtExpDate=null; // WTF!!!!!!
}