I've been studying sharepoint for a matter of days now so please bear with me if I'm missing something really obvious. I've followed a couple of guides that have got me familiar with the process of creating the basics to a sharepoint site by adding master pages, custom content types and then aspx pages for the content types.

On having a further look into the way it all 'clicks together' and how the code looks - I'm failing to see why there's an absence of code-behind files. Coming from an asp .net C# web application dev background I've naturally used C# a lot to add functionality to my site - but can't seem to do so within sharepoint solutions!? I understand that user controls come with C# code-behind capability - so does this mean all of the server-side functionality is found in the web controls and not actually on the page?

Thanks a lot.

  • 1
    Are you using Visual Studio to add ASPX pages and deploy? Those pages have code-behind just like normal ASP.NET pages.
    – Tschareck
    Apr 18, 2012 at 10:02
  • Yes I'm adding aspx pages and deploying. They don't appear to have code-behind files. I asked this question earlier on SO aswell and others seem to assert that they don't either. (stackoverflow.com/questions/10206756/…). I'd like to know why, if this is in fact the case. Apr 18, 2012 at 10:04
  • What do those ASPX pages actually do? If these are Applicaiton pages (deployed in _layouts) folder you can add code very easy. If these are List Forms, or Web Part Pages, i would recomand to use the way SharePoint does - create web parts which load User Controls - you get access to the entire page just as with ASP.NET Apr 18, 2012 at 10:28

2 Answers 2


There are two types of pages on a site: Site Pages, and Application Pages.

The first are created through the UI, or through SharePoint Designer (offers more flexibility) and it would be a huge security hole to let users attach their own code behind. You can only include user controls or webparts already marked as Safe in the web.config.

The latter is normally deployed by a Visual Studio package (.wsp), and are normal ASPX pages with code-behind. If you add an item of type "Application Page", it will be created with .cs and .designer.cs files already.

You can deploy site pages with inline code but as stated in the above linked article, as soon as they are customized by the user (with SharePoint Designer) the code will become blocked.

  • I think if you are using visual studio, you could develop pages with code behind and deploy to SitePages library (with safe control entries), but you cannot add code using SP Designer.
    – sssreddy
    Apr 19, 2012 at 20:00
  • Yes exactly. You can always deploy code in packages, but customizing pages (editing with SPD) will break them.
    – Louis
    Apr 20, 2012 at 10:51

if I may, it is actually known more as Code-Beside (its using Partial Classes more and more), but to get back to the matter at hand, there is Code-Behind/Besides, and certainly you can use the same way you did it with ASP.NET (even use Server-Code in the Design time via the %)

Mainly via Application pages using Visual Studio, or using Web Controls (User Controls too) in your web parts.

Hope it helps, C:\Marius

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.