0

Hi All,

I have a aspx page with few controls. When i am using reset button to reset the form its working fine before saving, its notworking after save the form. Can you help me on this.

i used OnClientClick="document.location.href=document.location.href;" for the Reset Button.

Thanks in advance.

2
Contributors
1
Reply
13
Views
3 Years
Discussion Span
Last Post by JorgeM
0

So, when you hit the reset button, you are simply reloading the page and of course since the page had no values when you first loaded it, reloading the page results in the same clean form.

However, when you submit the form, because of viewstate, the values are still populated in your form. If you disable viewstate for that page, the values will be cleared from your form on each postback. Your reset button, while it seems is working, its just simply performing an autopostback.

In your code behind, you can clear the input elements manually. But I would suggest doing this client side...no need to post back to the web server to simply clear a few textboxes...

Using javascript, or actually even easier with jQuery.

Something like this..

<script>
  $('#resetForm').click(function(){
    $('input').val("");
  });
</script>

Instead of using an ASPX control, just add an HTML button to your page. something like this..

<button id="resetForm">Reset</button>

Then just make sure that you are including jQuery in your page...in the head section..

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

Edited by JorgeM

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.