Master pages Need to Derive from Obout DLL with Code Behind

Posted on 2009-12-16
Last Modified: 2012-08-14
I have a master page (I am actually nesting masters - it is my top level master) that is using a code behind page that needs to inherit from the Obout AJAX page (as described here:  The problem is, I can't make it work.  It seems no matter what I try to do there is an error.  Here is what I have:

In the m.master page (my top level master) I have the following:
<%@ Master Language="VB" CodeFile="m.master.vb" Inherits="masterpages_m" %>
<%@ Register TagPrefix="oajax" Namespace="OboutInc" Assembly="obout_AJAXPage" %>
<%@ Register Assembly="obout_Combobox_NET" Namespace="OboutInc.Combobox" TagPrefix="obout" %>

In the code behind file:
Partial Class masterpages_m : Inherits OboutInc.oboutAJAXPage

    'Inherits System.Web.UI.MasterPage

End Class

Which gives me the error:
Server Error in '/' Application.

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

Line 1:  
Line 2:  Partial Class masterpages_m : Inherits OboutInc.oboutAJAXPage
Line 3:  
Line 4:      'Inherits System.Web.UI.MasterPage

Source File: D:\inetpub\vhosts\\httpdocs\masterpages\m.master.vb    Line: 2

This is probably simple - I am an old ASP programmer finally making the switch - and perhaps biting off more than I can chew on the first time out.  Let me know your thoughts.

P.S. - I have tried changing the Inherits tag in the m.master page and got the expected error that it needs to match up with the code behind (that is my summary anyway).

Question by:brandonmonahan
    LVL 15

    Accepted Solution

    From looking at the page you linked to, it's your content pages that should be derived from OboutInc.oboutAJAXPage not your master page.
    LVL 12

    Assisted Solution

    I believe the problem  is that the base type of oboutAJAXPage is System.Web.UI.Page and masterpages_m needs to inherit from something that dirives from System.Web.UI.MasterPage in order to have masterpage functionality.  I see 2 options off the bat.  1) the practical but slightly ugly option:  Don't use masterpages, but use a regular aspx page as the "master" and UserControls where you would use pages/contentplaceholders. 2) Elegant but probably impractical option:  create a custom masterpage class that either 1)derives from oboutAJAXPage and then implements all of the interfaces, etc of a masterpage, or 2) derives from masterpage and reimplements all of the oboutAJAXPage stuff.
    LVL 12

    Expert Comment

    NazoUK's solution is the right one, if the oboutAJAXPage functionality is not intended to be on the master page itself.

    Author Comment

    Well, that is not what I was hoping for.  I am at a bit of a loss on how to do this cleanly.  Unfortunately, the Obout objects also cannot be used in User Controls - I already tried that...  Again, it has to be connected with a page.  Well, perhaps I can integrate it against the standard AJAX.  What an issue...  Thanks for your help.

    Author Closing Comment

    I am splitting the points because NazoUK had it right but jamesrh really had it nailed down as to what I was trying to do and offered possible solutions...  Thanks.
    LVL 12

    Expert Comment

    Do you need to use it both in the "Master" and the inner items/controls?
    LVL 12

    Expert Comment

    If you do need to use the functionality at both levels, you might be able to expose the OboutInc stuff to the user controls through custom properties/methods on the page.  So the "Master" page inherits from OboutInc.oboutAJAXPage and the user controls rely on the fact that they are living inside this page.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now