_REALLY_ simple namespace question...

Discussion in 'ASP .Net' started by =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007.

  1. 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
     
    =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:f45qs8$83t$-c.dk...
    > 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, Jun 6, 2007
    #2
    1. Advertising

  3. =?ISO-8859-1?Q?Morten_N=F8rgaard?=

    Mark Rae Guest

    "Morten Nørgaard" <> wrote in message
    news:f45qs8$83t$-c.dk...

    > ... 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
     
    Mark Rae, Jun 6, 2007
    #3
  4. 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" <> wrote in message
    > news:f45qs8$83t$-c.dk...
    >> 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
    >>

    >
    >
     
    =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007
    #4
  5. Mark Rae skrev:
    > "Morten Nørgaard" <> wrote in message
    > news:f45qs8$83t$-c.dk...
    >
    >> ... 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
     
    =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007
    #5
  6. =?ISO-8859-1?Q?Morten_N=F8rgaard?=

    Mark Rae Guest

    "Morten Nørgaard" <> wrote in message
    news:f45tn1$8gv$-c.dk...

    > 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
     
    Mark Rae, Jun 6, 2007
    #6
  7. 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
     
    =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007
    #7
  8. 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
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jun 6, 2007
    #8
  9. =?ISO-8859-1?Q?Morten_N=F8rgaard?=

    Mark Rae Guest

    "Morten Nørgaard" <> wrote in message
    news:f45upe$8k8$-c.dk...

    > 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
     
    Mark Rae, Jun 6, 2007
    #9
  10. Mark Rae skrev:
    > "Morten Nørgaard" <> wrote in message
    > news:f45upe$8k8$-c.dk...
    >
    >> 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 :)
     
    =?ISO-8859-1?Q?Morten_N=F8rgaard?=, Jun 6, 2007
    #10
  11. =?ISO-8859-1?Q?Morten_N=F8rgaard?=

    abdul

    Joined:
    Jun 6, 2007
    Messages:
    1
    hello everyone :
    i am still getting some problem with asp.net 2005.what i did. i have create one class called User.vb and one function add() in that class but i can't execute the add() function in my .aspx page.

    thanks in advance
     
    abdul, Jun 6, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Èý¹â
    Replies:
    1
    Views:
    578
    William F. Robertson, Jr.
    Jul 29, 2003
  2. Replies:
    0
    Views:
    5,141
  3. Keiron Waites
    Replies:
    7
    Views:
    416
    Dennis M. Marks
    Feb 28, 2004
  4. =?ISO-8859-1?Q?Emmanuel_Thom=E9?=

    _really_ empty classes

    =?ISO-8859-1?Q?Emmanuel_Thom=E9?=, Feb 18, 2004, in forum: C++
    Replies:
    3
    Views:
    525
    =?ISO-8859-1?Q?Emmanuel_Thom=E9?=
    Feb 18, 2004
  5. Keiron Waites

    _REALLY_ simple HTML error driving me crazy

    Keiron Waites, Feb 26, 2004, in forum: Javascript
    Replies:
    5
    Views:
    98
Loading...

Share This Page