PC Review


Reply
Thread Tools Rate Thread

_REALLY_ simple namespace question...

 
 
=?ISO-8859-1?Q?Morten_N=F8rgaard?=
Guest
Posts: n/a
 
      6th Jun 2007
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

 
Reply With Quote
 
 
 
 
Paul Hadfield
Guest
Posts: n/a
 
      6th Jun 2007
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.

"Morten Nørgaard" <(E-Mail Removed)> wrote in message
news:f45qs8$83t$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      6th Jun 2007
"Morten Nørgaard" <(E-Mail Removed)> wrote in message
news:f45qs8$83t$(E-Mail Removed)...

> ... 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...


--
http://www.markrae.net

 
Reply With Quote
 
=?ISO-8859-1?Q?Morten_N=F8rgaard?=
Guest
Posts: n/a
 
      6th Jun 2007
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.
>
> "Morten Nørgaard" <(E-Mail Removed)> wrote in message
> news:f45qs8$83t$(E-Mail Removed)...
>> 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
>>

>
>

 
Reply With Quote
 
=?ISO-8859-1?Q?Morten_N=F8rgaard?=
Guest
Posts: n/a
 
      6th Jun 2007
Mark Rae skrev:
> "Morten Nørgaard" <(E-Mail Removed)> wrote in message
> news:f45qs8$83t$(E-Mail Removed)...
>
>> ... 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
 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      6th Jun 2007
"Morten Nørgaard" <(E-Mail Removed)> wrote in message
news:f45tn1$8gv$(E-Mail Removed)...

> 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"


--
http://www.markrae.net

 
Reply With Quote
 
=?ISO-8859-1?Q?Morten_N=F8rgaard?=
Guest
Posts: n/a
 
      6th Jun 2007
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
 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      6th Jun 2007
Morten Nørgaard wrote:
> 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


Yes, it was.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      6th Jun 2007
"Morten Nørgaard" <(E-Mail Removed)> wrote in message
news:f45upe$8k8$(E-Mail Removed)...

> 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... :-)


--
http://www.markrae.net

 
Reply With Quote
 
=?ISO-8859-1?Q?Morten_N=F8rgaard?=
Guest
Posts: n/a
 
      6th Jun 2007
Mark Rae skrev:
> "Morten Nørgaard" <(E-Mail Removed)> wrote in message
> news:f45upe$8k8$(E-Mail Removed)...
>
>> 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 :-)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: dumb namespace question - can't see library namespace from exeproject Arne Vajhøj Microsoft C# .NET 1 1st Aug 2010 09:49 PM
Simple data type question. namespace name 'Address' could not befound? karen.homersham@gmail.com Microsoft C# .NET 4 25th May 2008 01:16 AM
Very simple problem (does not exist in the class or namespace) Mark Allison Microsoft C# .NET 3 7th Sep 2004 12:42 PM
simple namespace question =?Utf-8?B?S2F0aWUgUw==?= Microsoft ASP .NET 3 16th Feb 2004 08:40 AM
Simple namespace problem Raheel Microsoft Dot NET Framework 5 24th Nov 2003 08:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:19 PM.