Reputation: 12861
Can I Simulate this Code With JQUERY or Javascript?
IEnumerable<TextBox> Textboxes = (from c in pnlform.Controlswhere object.ReferenceEquals(c.GetType(), typeof(TextBox))c).AsEnumerable().Cast<TextBox>();
foreach (TextBox item in Textboxes) {
item.Text = string.Empty;
}
i want to clear all textboxes without any roundtrip to server.
Upvotes: 0
Views: 4765
Reputation: 179256
Use the reset
button. It will reset all ( input
| select
| textarea
) elements within a form
to their default values. The default values are specified by the element like so:
<input type="text" name="someName" value="this is a default value" />
with radio buttons and check boxes, it will return them to their default checked state.
Edit to add:
Reset buttons work well as a "cancel" button if you have a form where you are making changes to existing data.
Upvotes: 1
Reputation: 187110
Seems like you are trying to clear textboxes inside a panel pnlform. So in your selector you can give a context
$("input:text", "#yourpanelid").val('');
Upvotes: 2
Reputation: 13747
In a click function I have a link with class reset:
$('.reset').click(function(){
$(':input','#formID')
.val('')
});
Upvotes: 1
Reputation: 73123
Don't really understand that code, but to clear a textbox with jQuery:
$('someselector').val('');
So to clear all textboxes on a page:
$('input[type=text]').val('');
Or you could use good old' form.reset()
Upvotes: 3