Refresh your Page using JavaScript

If you want to use JavaScript to refresh the page, you can use
  1. 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();
  2. 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;
  3. Also you can use self.location=self.location;
If you want to use JavaScript to redirect to another page, you can use
  • 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

Popular posts from this blog

Auto-Generating Filenames for InfoPath Forms

Creating Three-state workflow in SharePoint 2010

Microsoft Dynamics CRM integration with SharePoint