Moksha
Moksha

Reputation: 1030

Clear all fields after record inserted in asp.net

I have a small form of 4 fields, I am using Ajax to save record and give alert to user on same page. all is working fine but I want to clear all 4 fields after record is inserted and don't want user to press again and duplicate,

Right now I am using

this._studentName.text = "";

but is there any easy method to get same result coz I have another form where there are more then 40 fields and don't want write .text = "" 40 times

Upvotes: 0

Views: 1294

Answers (2)

Shady M. Najib
Shady M. Najib

Reputation: 2151

If it's applicable, Why not redirect to the same page? :)

Upvotes: 1

Xavier Poinas
Xavier Poinas

Reputation: 19733

If you use jQuery then you could write:

$('#formID input[type=text]').val('');

If you don't use jQuery then you could still call this.getElementsByTagName('input') and loop through the results to clear the values.

Upvotes: 1

Related Questions