Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

_REALLY_ simple namespace question...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morten Nørgaard - 06 Jun 2007 09:22 GMT
Hello everyone,

    I feel really dumb asking this, but I can't work it out. Searching
gives me nothing, I'm down to thinking it's a bug in Visual Studio 2005,
but of course it probably isn't...

    I want to add a namespace to my aspx file. I do this:

    using System;
    namespace test
    {
   
       public partial class _Default : System.Web.UI.Page
       {
           protected void Page_Load(object sender, EventArgs e)
            {

           }
       }

    }

   

... but I'm told all sorts of page errors. If I remove the
namespace-thing, nothing.

How can I add a namespace to my code-behind?

Thanks a million in advance,

Morten
Paul Hadfield - 06 Jun 2007 09:27 GMT
Wouldn't you need to add the namespace to the designer page too - note the
"partial class" syntax.  It's probably trying to have one part of the class
in the root namespace and the other in the test namespace.

- Paul.

> Hello everyone,
>
[quoted text clipped - 26 lines]
>
> Morten
Morten Nørgaard - 06 Jun 2007 10:07 GMT
Paul Hadfield skrev:
> Wouldn't you need to add the namespace to the designer page too - note the
> "partial class" syntax.  It's probably trying to have one part of the class
> in the root namespace and the other in the test namespace.

Hi Paul,

    thanks for the suggestion, I can see where you're headed. But I tried
that approach and alas it didn't aide me along.

But thanks again,

Morten

>  - Paul.
>
[quoted text clipped - 28 lines]
>>
>> Morten
Mark Rae - 06 Jun 2007 09:32 GMT
> ... but I'm told all sorts of page errors.

Like what...?

There's no point telling a technical newsgroup that you get "all sorts of
page errors" if you don't actually say what those errors are...

Signature

http://www.markrae.net

Morten Nørgaard - 06 Jun 2007 10:10 GMT
Mark Rae skrev:

>> ... but I'm told all sorts of page errors.
>
> Like what...?
>
> There's no point telling a technical newsgroup that you get "all sorts
> of page errors" if you don't actually say what those errors are...

Mark,

    touché. The reason I didn't give the error messages is in that my
VS.NET 2005 is a Danish version and I got stumped trying to translate
the Danish message into English ones. As far as I could tell they
weren't related to the error, giving me quite ridiculous possibles. But
if you'd care to invest the one minute it'd take you to create the page
in VS.NET yourselves, I'd be very grateful indeed. The code-behind is this:

using System;

namespace test
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}

... and the page looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title="fdsaf" /></head>
<body>    <form id="form1" runat="server"></form> </body>
</html>

That's really all there is to it. But won't compile... :-(

/Morten
Mark Rae - 06 Jun 2007 10:24 GMT
> That's really all there is to it. But won't compile... :-(

Indeed not, because it's now looking for a class called _Default, which no
longer exists...

Change Inherits="_Default" to Inherits="test_Default"

Signature

http://www.markrae.net

Morten Nørgaard - 06 Jun 2007 10:29 GMT
Morten Nørgaard skrev:
> Hello everyone,
>
> How can I add a namespace to my code-behind?

I discovered the solution: to add the name of the code-behind namespace
to the 'inherits' attribute of the page, i.e.
"inherits='mynamespacename.mypagename'".

Paul, this was what you were trying to tell me, right? :-)

/Morten
Göran Andersson - 06 Jun 2007 11:36 GMT
> Morten Nørgaard skrev:
>> Hello everyone,
[quoted text clipped - 8 lines]
>
> /Morten

Yes, it was. :)

Signature

Göran Andersson
_____
http://www.guffa.com

Mark Rae - 06 Jun 2007 11:38 GMT
> I discovered the solution: to add the name of the code-behind namespace to
> the 'inherits' attribute of the page, i.e.
> "inherits='mynamespacename.mypagename'".

As I mentioned... :-)

Signature

http://www.markrae.net

Morten Nørgaard - 06 Jun 2007 11:42 GMT
Mark Rae skrev:

>> I discovered the solution: to add the name of the code-behind
>> namespace to the 'inherits' attribute of the page, i.e.
>> "inherits='mynamespacename.mypagename'".
>
> As I mentioned... :-)

Yup - thanks everyone :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.