Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Posts Tagged ‘Custom Page’

Easiest Way To Add Custom Page to SharePoint

Posted by ken zheng on November 4, 2009

I found the easiest way to add custom page to SharePoint is to create a host aspx page and embed usercontrol inside, so next time if you have any update you can just update the usercontrol.

Below is the aspx inline page and I upload to Pages library

<%@ Page Language="C#"  EnableSessionState="true"  MasterPageFile="~masterurl/default.master"%>
<%@ Register src="~/_controltemplates/TestUserControl.ascx" tagname="TestUserControl" tagprefix="uc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
      <uc1:TestUserControl ID="JDEGLSearch" runat="server" />
</asp:Content>

The TestUserControl.ascx just a User Control created in the visual studio. You can add the ui into 12\TEMPLATE\CONTROLTEMPLATES

or you can add into _\12\TEMPLATE\LAYOUTS folder but which means everyone can access the page

<%@ Page language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" runat="server">
  <b>Hello</b>
</asp:Content>

Posted in Sharepoint | Tagged: | Leave a Comment »

Use Session in Custom Page: Session state can only be used when enableSessionState is set to true

Posted by ken zheng on November 4, 2009

If you received this error when use session in your custom aspx page deployed to SharePoint:

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.

If you add “EnableSessionState=”true” “ to your it should enable it but also you need to modify you web.config

The problem is that by default, Sharepoint does not allow server side code in .aspx pages by default. You need to enable this using PageParserPath. Add the PageParserPath inside of the PageParserPaths node of the web.config file, changing the virtual path to the path you want to enable. Or you can use /Pages/* as the value if they are in the same folder

Posted in Sharepoint | Tagged: , | Leave a Comment »