load asp.net page from javascript
I have a asp.net project.
On one of the pages i have a table that gets filled when the page gets loaded, every row has a delete button, when its clicked it deletes that row from the server and refreshes the page. i do this with a
WebMethod
That the javascript on call back redirects to that page using:
window.location.href = "HomePage.aspx";
The problem is that it doesnt really load the page again but it just refreshes it, that way the table displayed on the page still has the row that was deleted, even when it was really deleted.
I fill the table in the HomePage.aspx page like this:
<table id="pipesTbl">
<thead>
<tr>
<th>Name</th>
<th>Current Status</th>
<th>Last run summary</th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<%
foreach (var name in Names)
{%>
<tr>
<td><% Response.Write(name.age);%><br /</td>
<td><% Response.Write(name.age);%><br />2 hours and 22 minutes...</td>
<td>Good<br />01/07/2011</td>
</tr> 开发者_C百科
<%} %>
</tbody>
</table>
Any idea what i can do to make this work?
I think this might work
location.reload(true);
this is what the documentation says
reload(forceget) Reload the document from the current URL. forceget is a boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.
EDIT (comment that held solution): In case you are in a asp.net webforms project put this in the page load. If you are in an MVC project I think it must be in the controller (not sure)
c# version (for vb.net see comments):
Random rd = new Random();
Response.AddHeader("ETag", rd.Next(1111111, 9999999).toString());
Response.AddHeader("Pragma", "no-cache");
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();
Response.Expires = -1;
精彩评论