R – Asp.net Cancel Button

asp.netwebforms

I am trying this in my Form Load Event


cmdCancel.Attributes.Add("onClick", "document.forms[0].reset();return false;")

but it doesn't clear my form. My form is a "ContentPage", part of a masterpage.

Am I missing something?

Best Solution

Try this:

  cmdCancel.Attributes.Add("onClick","document.getElementById('" + this.Page.ClientId + "').reset(); return false;");