Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Doesn't compile page if I put the Class in a namespace...

Doesn't compile page if I put the Class in a namespace...

Scheduled Pinned Locked Moved ASP.NET
helpcsharpvisual-studio
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    signbit
    wrote on last edited by
    #1

    Hello, take a look at the following line of code...

    <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="_Default" %>

    however, if I put the class _Default in a namespace, say MyNamespace and try the following line:

    <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="MyNamespace._Default" %>

    VS generates an error:

    Could not load type 'MyNamespace._Default'

    Any help would be highly appreciated...

    - A programmer's national anthem; "AAAAAHHHHH!!!!"

    R D 2 Replies Last reply
    0
    • S signbit

      Hello, take a look at the following line of code...

      <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="_Default" %>

      however, if I put the class _Default in a namespace, say MyNamespace and try the following line:

      <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="MyNamespace._Default" %>

      VS generates an error:

      Could not load type 'MyNamespace._Default'

      Any help would be highly appreciated...

      - A programmer's national anthem; "AAAAAHHHHH!!!!"

      R Offline
      R Offline
      RaviJJain
      wrote on last edited by
      #2

      remove the _ (underscore) from the Inherits="MyNameSpace._Default" to Inherits="MyNameSpace.Default"

      S 1 Reply Last reply
      0
      • R RaviJJain

        remove the _ (underscore) from the Inherits="MyNameSpace._Default" to Inherits="MyNameSpace.Default"

        S Offline
        S Offline
        signbit
        wrote on last edited by
        #3

        Thanks for the reply pal, have tried that already, doesn't matter what the name of the class is, it still won't compile... :(

        - A programmer's national anthem; "AAAAAHHHHH!!!!"

        1 Reply Last reply
        0
        • S signbit

          Hello, take a look at the following line of code...

          <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="_Default" %>

          however, if I put the class _Default in a namespace, say MyNamespace and try the following line:

          <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="MyNamespace._Default" %>

          VS generates an error:

          Could not load type 'MyNamespace._Default'

          Any help would be highly appreciated...

          - A programmer's national anthem; "AAAAAHHHHH!!!!"

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          signbit wrote:

          however, if I put the class _Default in a namespace, say MyNamespace and try the following line: <%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="MyNamespace._Default" %>

          Just to be sure, did you put codebehing class (in .cs file) into same namespace? I don't feel like firing up IDE, but I think that pages are always in some namespace (default project namespace), and you don't prefix class name in Inherits page directive. Did you try it without MyNamespace, add it only in codebehind?


          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups