Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Error loading a page with code behind

  Asked By: Fallon    Date: Jul 03    Category: Sharepoint    Views: 1987

I've created a simple page with code behind and I'm getting the error
below. I've validated that the dll exists in the GAC and the token is
correct. The solution compiles fine. Any suggestions would be
appriciated.

Share: 

 

8 Answers Found

 
Answer #1    Answered By: Amanda Lewis     Answered On: Jul 03

Does the Inherits attribute of the @Page directive have the entire namespace,
class and 4-part assembly name?

<%@Page Inherits=Namespace.Class, Full.Assembly.Name, Version=#.#.#.#,
Culture=neutral, PublicKeyToken=2a96...." %>

 
Answer #2    Answered By: Cassie Snyder     Answered On: Jul 03

I have duobled-checked this and I do not see anything wrong with
this.
I've attached the details below. Can you see anything wrong?

Code from the .aspx page...
<%@ page  Language="C#" MasterPageFile="~/_layouts/application.master"
AutoEventWireup="true" CodeBehind="RequestASite.aspx.cs"
Inherits="MMMRequestASite.RequestASite, RequestASite,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=1417654614344272" %>


Code from .aspx.cs code-behind page...
namespace MMMRequestASite
{
public partial class RequestASite : System.Web.UI.Page


Stuff in the asseblyInfo.cs...
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("MMMRequestASite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("United States")]
[assembly: AssemblyProduct("MMMRequestASite")]
[assembly: AssemblyCopyright("Copyright © United States 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

 
Answer #3    Answered By: Parijat Pathak     Answered On: Jul 03

SharePoint doesn't support code  behind sheets. You need to compile the code
behind sheet as a full class, not a partial class, and then set the @ page
directive to inherit from it after removing the SRC= attribute. When specifying
the Inherits you need to use the five part form of the class name with part one
being the full path to the class inside the assembly and the other four parts
being the strong name of the assembly.

 
Answer #4    Answered By: Ella Sargent     Answered On: Jul 03

Here is my code  in the aspx...

<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"
AutoEventWireup="true" CodeBehind="RequestASite.aspx.cs"
Inherits="MMMRequestASite.RequestASite, RequestASite,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=1417654614344272" %>

And the code behind...

namespace MMMRequestASite
{
public partial class RequestASite : System.Web.UI.Page
{

 
Answer #5    Answered By: Ahmad Johns     Answered On: Jul 03

Remove the AutoEventWireup and CodeBehind attributes. I also specify
CompilationMode="never" so that the runtime doesn't try to create a partial
class.

If you need to handle an event, you'll need to wire up the event handler
yourself when the control is created.

You will lose a little bit of Visual Studio convenience without the code  behind
attribute, but that shouldn't be a big deal.

 
Answer #6    Answered By: Roxanna Hendricks     Answered On: Jul 03

I have removed the AutoEventWireup and CodeBehind attributes and
added CompilationMode="never". I am now getting "Error 1 Missing
partial modifier on declaration of type 'AccordionTest2._Default';
another partial declaration of this type exists  when I try to build
the project.

Also, I don't know what it means to 'wire up the event handler
yourself'. Does this have something to do with the Designer.cs file?

 
Answer #7    Answered By: Stacia Guy     Answered On: Jul 03

My experience is that you need the partial class declaration in your code  file.
It seems that you are using my advice about the .aspx file.

 
Answer #8    Answered By: Kacy Bright     Answered On: Jul 03

Remove the CodeBehind= setting from the Page and the partial declaration from
the class.

 
Didn't find what you were looking for? Find more on Error loading a page with code behind Or get search suggestion and latest updates.




Tagged: