I Am creating a SharePoint user control,in which I have to use buttons and the c# code so I used asp:button but when am deploying control on page to test then and after clicking on button this click action reload/refresh he entire page,which I dont want.

So how can I prevent page from getting refresh after clicking button?


1 Answer 1


If you're on the page where Minimal Download Strategy (aka MDS, see here for a first definition) is used (default behavior on a Team site), then it means your control is not MDS-compatible. As soon as your control becomes MDS-aware, all the MDS infrastructure will take care of "not reloading the entire page when you navigate" for you.
You need at least to mark it with the MdsCompliant attribute:

public class MyUserControl : UserControl

See e.g. this blog post by Steve Lineberry for more info.

If you're on a Publishing site where MDS is not enabled, what you want is to change the default behavior of ASP.NET buttons (that perform actual postbacks to the server when an event happens on the client, like the button click).
This is then a pure ASP.NET question (i.e. not SharePoint specific): how to prevent a user action to trigger an actual postback with the page being reloaded. The answer is called "Ajax". Ajax allows you to "intercept" user actions client-side and to emit "background" HTTP request to the server (with the mean of JavaScrip code).
This technique is very well and very commonly described in various articles (note that it's not even ASP.NET-specific as it's used everywhere on the Web, independantly of the technology used by the server).
You can look here, here, here, or at a lot of other articles.

  • i tried these both approaches but none of them worked,can you suggest some others?
    – Madhav
    Jan 4, 2017 at 13:55
  • What did you try exactly? What do you mean by "not working"? Are you in a MDS site or not? The Ajax approach is not something that may or may not work. It's a concept that is (almost) always implementable, despite difficulties you may encounter depending on your context...
    – Evariste
    Jan 4, 2017 at 15:58
  • no am not in MDS site
    – Madhav
    Jan 5, 2017 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.