2

I want to add a code behind file to check the user's group. But I cannot find the code behind file for home.aspx. How can I create one?

0

.cs file types are not visible for SharePoint pages/pagelayouts.

In order for you to add your own to one of the Out-of-the-box pages like Home.aspx you'll have to

  • Create a new .cs file in Visual Studio which derives from either Page or WebPartPage

Example:

public class MyCustomCodeBehindForHomeAspx : Page
  • Then you have to open Home.aspx in e.g. SharePoint Designer and add the fully qualified name

Example:

<%@ Page 
    Language="C#" 
    DynamicMasterPageFile="~masterurl/default.master" 
    Inherits="MyNamspace.MyCustomCodeBehindForHomeAspx, fully qualified assembly name here"
    %>
  • Do I have to write "MyNamspace" or the namespace my .cs file is in? @Daniel Ziga – A Beginner Apr 21 '15 at 9:05
  • @ABeginner Namespace of your .cs file – user2536 Apr 21 '15 at 9:08
  • It is throwing me this error : Could not load the assembly '$SharePoint.Project.AssemblyFullName$'. Make sure that it is compiled before accessing the page. @Daniel Ziga – A Beginner Apr 21 '15 at 10:16
  • Replace $SharePoint.Project.AssemblyFullName$ with your dll's info – user2536 Apr 21 '15 at 10:43
  • On using gacutil command it says 0 items exist in global assembly cache for mynameapace – A Beginner Apr 21 '15 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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