2

I added an application page to my module and now I want to covert it to a web part page. In the code behind I changed the inheritance to WebPartPage.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace Certco.SRPWebPart.Layouts.Certco.SRPWebPart
{
public partial class SRPMain : WebPartPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
}
}

I also changed the page code to:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"   Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral,   PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SRPMain.aspx.cs" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage , Microsoft.Sharepoint, Version=14.0.0.0,Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" %>



<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table>

I receive this error when running the page: Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'WebPartPages:WebPartZone'.

Source Error:

Line 17: Line 18: Line 19: Line 20: Line 21:

What am I missing?

1
  • Please mark it as answer, if my suggested solution has helped you. Jun 25, 2012 at 13:02

1 Answer 1

2

Register the tagprefix WebPartPages and try again:

<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Remove the CodeBehind attibute, instead add server side script directly on the Aspx page using Script for example:

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

<script runat="server">
    // The following variables are visible to all procedures 
    // within the <script> block.
    String str;
    int i;
    int i2;

    int DoubleIt(int inpt)
    {
        // The following variable is visible only within 
        // the DoubleIt procedure.
        int factor = 2;

        return inpt * factor;
    }
</script>
11
  • Now I receive this error: Jun 12, 2012 at 22:24
  • Compiler Error Message: CS0433: The type 'Microsoft.SharePoint.WebPartPages.WebPartPage' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll' and 'c:\Windows\assembly\GAC_MSIL\Certco.SRPWebPart\1.0.0.0__72ae893f734951b8\Certco.SRPWebPart.dll' Source Error: Line 139: Line 140: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] Line 141: public class SRPMAIN_ASPX__554292766 : global::Microsoft.SharePoint.WebPartPages.WebPartPage, System.Web.IHttpHandler { Line 142: Line 143: Jun 12, 2012 at 22:24
  • The reason I did not use the "/layouts/v4.master" is because I received this error before: The referenced file '/_layouts/v4.master' is not allowed on this page. Jun 12, 2012 at 22:33
  • have you tried resetting the IIS? Jun 12, 2012 at 22:35
  • As in stopping and starting the IIS? Jun 12, 2012 at 22:37

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.