Friday, April 29, 2011

Sharepoint controls in ASP.NET application

Is there a way I can use the sharepoint controls in a ASP.NET web application like any other controls that come out of box for ASP.NET? If yes, what are the pre-requisites I need to install?

Thank you, Harsha

From stackoverflow
  • Yes, you can use SharePoint "controls" in an ASP.NET application, as long as the application is running in SharePoint.

    In other words, the prerequisite is SharePoint.

    Ahmad Farid : how can we do that?
    Harsha : There are so many nice controls in Sharepoint. It would be great if we can use them outside (in ASP.NET application alone)
  • What specific controls are you referring to? Those that you find in SharePoint Designer?

    If you are referring to Web Parts in WSS v3, those that are using the ASP.NET Web Part as the base web part (the recommended approach) may work fine in ASP.NET since the Web Part class inherits from Panel which inherits from Web Control (going from memory here) - all ASP.Net classes. It would just depend on whether the web part has any SharePoint specific code which is highly dependent upon the web part.

  • Host the application in SharePoint's _layouts directory (see this video for more details). Your ASP.NET app will then be "running in SharePoint" and have access to all SharePoint controls.

    Note that some controls don't work unless they are running on an actual SharePoint page.

  • Most controls have internal dependencies on SharePoint (i.e. they use SPContext or SPWeb internally). Also, since they are contained within the Sharepoint Assemblies, you can not just take the .dlls and put them in your app.

    In short: In most cases, it will be better to re-build them using reflector. Which one are you looking at?

0 comments:

Post a Comment