Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Page Directive - autoeventwireup

  Asked By: Angelique    Date: Feb 14    Category: Sharepoint    Views: 7771

I am trying to develop my own application to run on sharepoint.
I works fine in my dev environment. To deploy it to sharepoint server, I put the dll into GAC and copied aspx pages and all that.

When I click 'preview in brower', I get an error: The attribute 'autoeventwireup' is not allowed in this page.

The page I was trying to open starts with page directive ..:

<%@ page language="C#" autoeventwireup="true" masterpagefile="MasterPage.master" inherits="..." title="..." %>

If i delete autoeventwire attribute, would code-behind code such as Page_Load() work fine?!

Even though I delete autoeventwire attribute and run the page again, I still get the same error.

Am I not allowed to use autoeventwireup attribute in sharepoint?



1 Answer Found

Answer #1    Answered By: Harihar Sonnad     Answered On: Feb 14

This is related to your other issue. If you want your page  to run  within SharePoint's context, sharepoint  has to be sure that the code  is "safe". The best way to do that is to have the code compiled and in a trusted location. By putting your DLL in the GAC, you're ensuring that the DLL has been digitally signed, and SharePoint will consider it safe to execute. What this means, though, is you won't be using the regular ASP.NET processing engine, in the sense that SharePoint won't be dynamically compiling your code-behind pages  the way ASP.NET does. Since that's the case, you won't be specifying code behind ways in the typical way you would in an ASP.NET application. Instead, you'll be changing the "Inherits" attribute  to point to a class reference in the compiled DLL you put  in the GAC, not at a class in your code-behind  page.

Now, that being said, you can do things in reverse, to some extent. You can put your aspx  page in the SharePoint Layouts directory in the "12 hive", and have the page execute using ASP.NET, and try to retrieve the SharePoint conext; when you do that, you can use a code-behind page. Here are some examples.

Didn't find what you were looking for? Find more on Page Directive - autoeventwireup Or get search suggestion and latest updates.