Refresh your Page using JavaScript
If you want to use JavaScript to refresh the page, you can use
- Post request, same as click the refresh button on the browser. If there is any control in the form then after the form was submitted for the first time, if you click this, it will be a post method coming with the IE alert. Use location.reload();
- Get request: If there is any control in the form then after the form was submitted for the first time, if you click this, it will still be a get method which means the form will not be submitted again. Use window.location=window.location;
- Also you can use self.location=self.location;
- location.replace('webform.aspx'); => get request, does not create a history entry so browser back button disabled if no history before
- location.href='webform.aspx'; => get request, create a history entry so browser back button works
- window.location='webform.aspx'; => get request, create a history entry so browser back button works
Implementation of Clear/Refresh Logic on Button Click
void ClearButton_Click(object sender, EventArgs e)
{
Context.Response.Write("<script>window.location=window.location;</script>");
}
Comments
Post a Comment