Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh a page, without resending POST data(ASP.NET)

How to refresh and reload the page without resending the POST data?

I have tried location.reload() which works absolutely fine on Chrome(which was the testing environment while development). But IE and Firefox went into an Infinite Loop in JS - reposting a lot of junk/duplicate data.

Note: However, I just want to refresh the page to clear all the form contents. I am also registering a start up script after Submit, that will show the alert message that data was added successfully.

HELP!

like image 406
Mr Lonely Avatar asked Dec 21 '12 07:12

Mr Lonely


4 Answers

Try this:

window.location.href = window.location.href;
like image 175
karaxuna Avatar answered Nov 15 '22 06:11

karaxuna


location.href = location.href + '?' + Math.random();

This should work.

like image 29
Junnan Wang Avatar answered Nov 15 '22 06:11

Junnan Wang


In your code add:

Response.Redirect(Request.RawUrl)
like image 5
Ryan McDonough Avatar answered Nov 15 '22 08:11

Ryan McDonough


If you just want to clear the form, why not:

<input type="reset" value="Clear Fields">

You could also do it using:

document.getElementById('<%=form1.ClientID%>').reset();

Seems a waste to reload the page unless you need to do something else as well.

like image 2
webnoob Avatar answered Nov 15 '22 07:11

webnoob